diff --git a/Control/IOVSvc/CMakeLists.txt b/Control/IOVSvc/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..45c3b65760c52fcc7880977407e561db9b63c743 --- /dev/null +++ b/Control/IOVSvc/CMakeLists.txt @@ -0,0 +1,45 @@ +################################################################################ +# Package: IOVSvc +################################################################################ + +# Declare the package name: +atlas_subdir( IOVSvc ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + Control/AthenaKernel + Control/SGTools + Control/StoreGate + GaudiKernel + PRIVATE + AtlasTest/TestTools + Event/EventInfo ) + +# External dependencies: +find_package( Boost COMPONENTS filesystem thread system ) + +# Component(s) in the package: +atlas_add_library( IOVSvcLib + src/*.cxx + PUBLIC_HEADERS IOVSvc + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel SGTools GaudiKernel StoreGateLib SGtests + PRIVATE_LINK_LIBRARIES TestTools EventInfo ) + +atlas_add_component( IOVSvc + src/components/*.cxx + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel SGTools StoreGateLib SGtests GaudiKernel TestTools EventInfo IOVSvcLib ) + +atlas_add_test( IOVSvcTool_test + SOURCES + test/IOVSvcTool_test.cxx + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel SGTools StoreGateLib SGtests GaudiKernel TestTools EventInfo IOVSvcLib + EXTRA_PATTERNS "^HistogramPersis.* INFO|^IOVSvc +DEBUG|^IOVSvcTool +DEBUG" + ENVIRONMENT "JOBOPTSEARCHPATH=${CMAKE_CURRENT_SOURCE_DIR}/share" ) + +# Install files from the package: +atlas_install_joboptions( share/IOVSvc.txt share/IOVSvc.py ) + diff --git a/Control/IOVSvc/IOVSvc/CBNode.h b/Control/IOVSvc/IOVSvc/CBNode.h index b27a340b621cc3e0b696c848fc2c8e26c9d8a418..5819e00f3a73a9943e16bbf4c7a6d2fd61c5f2e8 100755 --- a/Control/IOVSvc/IOVSvc/CBNode.h +++ b/Control/IOVSvc/IOVSvc/CBNode.h @@ -21,11 +21,11 @@ #include <string> #ifndef ATHENAKERNEL_IOVSVCDEFS_H - #include "AthenaKernel/IOVSvcDefs.h" +#include "AthenaKernel/IOVSvcDefs.h" #endif #ifndef SGTOOLS_CALLBACKID_H - #include "SGTools/CallBackID.h" +#include "SGTools/CallBackID.h" #endif namespace SG { @@ -41,17 +41,17 @@ public: public: bool operator() ( const CBNode &n1, const CBNode &n2 ) const { if ( n1.level() != n2.level() ) { - return ( n1.level() < n2.level() ); + return ( n1.level() < n2.level() ); } else { - return ( n1.serial() < n2.serial() ); + return ( n1.serial() < n2.serial() ); } } bool operator() ( const CBNode *n1, const CBNode *n2 ) const { if ( n1->level() != n2->level() ) { - return ( n1->level() < n2->level() ); + return ( n1->level() < n2->level() ); } else { - return ( n1->serial() < n2->serial() ); + return ( n1->serial() < n2->serial() ); } } }; @@ -64,6 +64,9 @@ public: void addParent(CBNode* parent); void addChild(CBNode* child); + bool delParent(CBNode* parent); + bool delChild(CBNode* child); + const std::set<CBNode*>& children() const { return m_children; } const std::set<CBNode*>& parents() const { return m_parents; } diff --git a/Control/IOVSvc/IOVSvc/CBTree.h b/Control/IOVSvc/IOVSvc/CBTree.h index ca8f152b7db1bff63859bb73d3b10793a3d3646b..4c3506453ae8df73c27dcd16080c4841f18bfd3c 100755 --- a/Control/IOVSvc/IOVSvc/CBTree.h +++ b/Control/IOVSvc/IOVSvc/CBTree.h @@ -18,11 +18,11 @@ *****************************************************************************/ #ifndef IOVSVC_CBNODE_H - #include "IOVSvc/CBNode.h" +#include "IOVSvc/CBNode.h" #endif #ifndef ATHENAKERNEL_IOVSVCDEFS_H - #include "AthenaKernel/IOVSvcDefs.h" +#include "AthenaKernel/IOVSvcDefs.h" #endif #include <set> @@ -44,7 +44,7 @@ public: CBNode* addNode(const std::string& name, CBNode* parent); CBNode* addNode(const SG::DataProxy* proxy, const std::string& name); CBNode* addNode(BFCN* fcn, const CallBackID& cb, - const SG::DataProxy* parent_proxy); + const SG::DataProxy* parent_proxy); CBNode* addNode(BFCN* fcn, const CallBackID& cb, BFCN* parent_fcn); CBNode* replaceProxy(const SG::DataProxy* pOld, const SG::DataProxy* pNew); @@ -56,9 +56,13 @@ public: CBNode* findNode(const std::string& name, CBNode* start) const; CBNode* findNode(const SG::DataProxy* proxy) const; + CBNode* findNode(const SG::DataProxy* proxy, CBNode* start) const; + CBNode* findNode(BFCN* fcn) const; CBNode* findNode(BFCN* fcn, CBNode* start) const; + bool delNode(const SG::DataProxy* prx); + void printTree() const; void printTree( CBNode* start ) const; @@ -67,8 +71,8 @@ public: void listNodes() const; void listNodes( const int& level, - nodeSet::const_iterator& start, - nodeSet::const_iterator& end ) const; + nodeSet::const_iterator& start, + nodeSet::const_iterator& end ) const; void cascadeTrigger(const bool b, CBNode* start) const; void cascadeTrigger(const bool b, BFCN* fcn) const; diff --git a/Control/IOVSvc/IOVSvc/CondSvc.h b/Control/IOVSvc/IOVSvc/CondSvc.h new file mode 100644 index 0000000000000000000000000000000000000000..1375044f4edd74c290dddc73a28e473c7358bfe6 --- /dev/null +++ b/Control/IOVSvc/IOVSvc/CondSvc.h @@ -0,0 +1,94 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef IOVSVC_CONDSVC_H +#define IOVSVC_CONDSVC_H 1 + +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/Service.h" +#include "GaudiKernel/EventIDBase.h" +#include "GaudiKernel/EventIDRange.h" +#include "AthenaBaseComps/AthService.h" +#include "StoreGate/StoreGateSvc.h" +#include "AthenaBaseComps/AthService.h" + +#include <map> +#include <set> +#include <vector> +#include <mutex> + +class CondSvc: public extends1<AthService, ICondSvc> { +public: + + CondSvc(const std::string& name, ISvcLocator* svc); + ~CondSvc(); + + virtual StatusCode initialize(); + virtual StatusCode finalize(); + + // from ICondSvc +public: + virtual StatusCode regHandle(IAlgorithm* alg, const Gaudi::DataHandle& id, + const std::string& key); + + virtual bool getInvalidIDs(const EventContext*, DataObjIDColl& ids); + virtual bool getValidIDs(const EventContext*, DataObjIDColl& ids); + virtual bool getIDValidity(const EventContext*, DataObjIDColl& validIDs, + DataObjIDColl& invalidIDs); + + virtual std::set<std::string> getUnchangedAlgs( const DataObjIDColl& ); + + virtual StatusCode getRange(const std::string&, const EventContext*, EventIDRange&, + ICondSvc::dbData_t&) const; + + virtual const std::set<IAlgorithm*>& condAlgs() const { return m_condAlgs; } + + virtual void dump() const; + +private: + + class iAlgHasher { + public: + std::size_t operator()(const IAlgorithm * a) const { + return ( iAlgHasher()(*a)); + } + std::size_t operator()(const IAlgorithm& a) const { + return (a.nameKey().__hash__()); + } + + bool operator()(const IAlgorithm* lhs, const IAlgorithm* rhs) const { + return ( iAlgHasher()(*lhs,*rhs)); + } + bool operator()(const IAlgorithm& lhs, const IAlgorithm& rhs) const { + return ( lhs.nameKey() < rhs.nameKey() ); + } + + }; + + bool parse(EventIDRange& t, const std::string& s); + bool parse(IOVEntryT<ICondSvc::dbData_t>& t, const std::string& s); + + StatusCode readDbFile(const std::string&); + + ServiceHandle<StoreGateSvc> m_sgs; + + std::string m_file; + + typedef std::set<IAlgorithm*, iAlgHasher> IAlgHashSet; + typedef std::map<DataObjID, IAlgHashSet> id_map_t; + typedef std::map<IAlgorithm*, DataObjIDColl, iAlgHasher> alg_map_t; + id_map_t m_idMap; + alg_map_t m_algMap; + + std::map<std::string, DataObjID> m_keyMap; + std::set<IAlgorithm*> m_condAlgs; + + typedef std::map<std::string, std::vector<IOVEntryT<ICondSvc::dbData_t>>> registry_t; + registry_t m_registry; + + mutable std::recursive_mutex m_lock; + +}; + +#endif diff --git a/Control/IOVSvc/IOVSvc/IIOVSvcTool.h b/Control/IOVSvc/IOVSvc/IIOVSvcTool.h index 99a0da36c7d0be08097db5e82c2bc710774be8f0..a1b99de8e7b85aaa1a9fe88c758f94cf7bcbe835 100644 --- a/Control/IOVSvc/IOVSvc/IIOVSvcTool.h +++ b/Control/IOVSvc/IOVSvc/IIOVSvcTool.h @@ -16,6 +16,7 @@ class IOVRange; class IOVTime; +class IOpaqueAddress; namespace SG { class TransientAddress; @@ -23,7 +24,7 @@ namespace SG { } class IIOVSvcTool : virtual public IAlgTool { - public: +public: /// Retrieve interface ID static const InterfaceID& interfaceID() { @@ -39,47 +40,54 @@ class IIOVSvcTool : virtual public IAlgTool { // register callback functions virtual StatusCode regFcn(SG::DataProxy *dp, const CallBackID c, - const IOVSvcCallBackFcn& fcn, bool trigger) = 0; + const IOVSvcCallBackFcn& fcn, bool trigger) = 0; virtual StatusCode regFcn(const CallBackID c1, - const CallBackID c2, - const IOVSvcCallBackFcn& fcn2, - bool trigger) = 0; + const CallBackID c2, + const IOVSvcCallBackFcn& fcn2, + bool trigger) = 0; virtual StatusCode regFcn(const IAlgTool* ia, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger) = 0; + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger) = 0; // Update Range from dB virtual StatusCode setRange(const CLID& clid, const std::string& key, - IOVRange&) = 0; + IOVRange&) = 0; virtual StatusCode getRange(const CLID& clid, const std::string& key, - IOVRange& iov) const = 0; + IOVRange& iov) const = 0; // Subscribe method for DataProxy. key StoreGate key virtual StatusCode regProxy( const SG::DataProxy *proxy, - const std::string& key ) = 0; + const std::string& key ) = 0; + + virtual StatusCode deregProxy( const SG::DataProxy *proxy ) = 0; + virtual StatusCode deregProxy( const CLID& clid, const std::string& key ) = 0; + + // Replace a registered proxy with a new version virtual StatusCode replaceProxy( const SG::DataProxy *pOld, - const SG::DataProxy *pNew ) = 0; + const SG::DataProxy *pNew ) = 0; // Another way to subscribe virtual StatusCode regProxy( const CLID& clid, const std::string& key ) = 0; // Get IOVRange from db for current event virtual StatusCode getRangeFromDB(const CLID& clid, const std::string& key, - IOVRange& range, std::string &tag) const = 0; + IOVRange& range, std::string &tag, + IOpaqueAddress*& ioa) const = 0; // Get IOVRange from db for a particular event virtual StatusCode getRangeFromDB(const CLID& clid, const std::string& key, - const IOVTime& time, - IOVRange& range, std::string &tag) const = 0; + const IOVTime& time, + IOVRange& range, std::string &tag, + IOpaqueAddress*& ioa) const = 0; // Set a particular IOVRange in db (and memory) virtual StatusCode setRangeInDB(const CLID& clid, const std::string& key, - const IOVRange& range, - const std::string &tag) = 0; + const IOVRange& range, + const std::string &tag) = 0; // supply a list of TADs whose proxies will be preloaded virtual StatusCode preLoadTAD( const SG::TransientAddress * ) = 0; @@ -90,7 +98,7 @@ class IIOVSvcTool : virtual public IAlgTool { // return list of tools (or functions) that have been triggered by key // will return FAILURE if no tools found, or no key found virtual StatusCode getTriggeredTools(const std::string& key, - std::set<std::string>& tools) = 0; + std::set<std::string>& tools) = 0; virtual StatusCode reinitialize() = 0; @@ -101,6 +109,9 @@ class IIOVSvcTool : virtual public IAlgTool { virtual void resetAllProxies() = 0; + virtual void ignoreProxy(const SG::DataProxy* proxy) = 0; + virtual void ignoreProxy( const CLID& clid, const std::string& key) = 0; + }; #endif diff --git a/Control/IOVSvc/IOVSvc/IOVAddress.h b/Control/IOVSvc/IOVSvc/IOVAddress.h index 9d243936f1812d324e1934ff57ceee871107cf45..592e2fb6ba31ceff270e2c95870013f938c6fe5a 100755 --- a/Control/IOVSvc/IOVSvc/IOVAddress.h +++ b/Control/IOVSvc/IOVSvc/IOVAddress.h @@ -6,11 +6,11 @@ #define IOVSVC_IOVADDRESS_H #ifndef GAUDIKERNEL_IOPAQUEADDRESS_H - #include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/IOpaqueAddress.h" #endif #ifndef GAUDIKERNEL_CLASSID_H - #include "GaudiKernel/ClassID.h" +#include "GaudiKernel/ClassID.h" #endif class IOVAddress: public IOpaqueAddress { @@ -31,14 +31,14 @@ protected: IOVRange m_range; - public: +public: // Dummy constructor IOVAddress() : m_refCount(0), - m_svcType(0), - m_clID(0), - m_pRegistry(0) + m_svcType(0), + m_clID(0), + m_pRegistry(0) { m_ipar[0]=m_ipar[1]==0xFFFFFFFF; } @@ -60,23 +60,23 @@ protected: /// Standard Constructor IOVAddress(long svc, - const CLID& clid, - const std::string& p1, - const std::string& p2, - unsigned long ip1, - unsigned long ip2, - IOVRange range) - : m_refCount(0), - m_svcType(svc), - m_clID(clid), - m_pRegistry(0), - m_range(range) - { - m_par[0] = p1; - m_par[1] = p2; - m_ipar[0] = ip1; - m_ipar[1] = ip2; - } + const CLID& clid, + const std::string& p1, + const std::string& p2, + unsigned long ip1, + unsigned long ip2, + IOVRange range) + : m_refCount(0), + m_svcType(svc), + m_clID(clid), + m_pRegistry(0), + m_range(range) + { + m_par[0] = p1; + m_par[1] = p2; + m_ipar[0] = ip1; + m_ipar[1] = ip2; + } /// Standard Destructor virtual ~IOVAddress() { diff --git a/Control/IOVSvc/IOVSvc/IOVSvc.h b/Control/IOVSvc/IOVSvc/IOVSvc.h index 3408f151527690a838d7c4dbb24e9653aa607d6d..61383ac2e467ad171241973bc5e22c72fe1e6091 100755 --- a/Control/IOVSvc/IOVSvc/IOVSvc.h +++ b/Control/IOVSvc/IOVSvc/IOVSvc.h @@ -19,52 +19,54 @@ #include "AthenaBaseComps/AthService.h" #ifndef KERNEL_STATUSCODES_H - #include "GaudiKernel/StatusCode.h" +#include "GaudiKernel/StatusCode.h" #endif #ifndef GAUDIKERNEL_CLASSID_H - #include "GaudiKernel/ClassID.h" +#include "GaudiKernel/ClassID.h" #endif #ifndef GAUDIKERNEL_MSGSTREAM_H - #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/MsgStream.h" #endif #ifndef SGTOOLS_DATAPROXY_H - #include "SGTools/DataProxy.h" +#include "SGTools/DataProxy.h" #endif #ifndef ATHENAKERNEL_IIOVSVC_H - #include "AthenaKernel/IIOVSvc.h" +#include "AthenaKernel/IIOVSvc.h" #endif #ifndef IOVSVC_IOVENTRY_H - #include "IOVSvc/IOVEntry.h" +#include "IOVSvc/IOVEntry.h" #endif #ifndef SGTOOLS_CALLBACKID_H - #include "SGTools/CallBackID.h" +#include "SGTools/CallBackID.h" #endif #ifndef ATHENAKERNEL_IOVTIME_H - #include "AthenaKernel/IOVTime.h" +#include "AthenaKernel/IOVTime.h" #endif #ifndef ATHENAKERNEL_IOVSVCDEFS_H - #include "AthenaKernel/IOVSvcDefs.h" +#include "AthenaKernel/IOVSvcDefs.h" #endif #include "IOVSvc/IIOVSvcTool.h" #ifndef _CPP_SET - #include <set> +#include <set> #endif #ifndef _CPP_MAP - #include <map> +#include <map> #endif #ifndef _CPP_LIST - #include <list> +#include <list> #endif #ifndef _CPP_STRING - #include <string> +#include <string> #endif +#include <mutex> #include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ICondSvc.h" // Forward declarations template <class TYPE> class SvcFactory; @@ -84,7 +86,7 @@ namespace SG { } class IOVSvc: virtual public AthService, - virtual public IIOVSvc { + virtual public IIOVSvc { public: @@ -101,71 +103,86 @@ public: /// register callback functions StatusCode regFcn(SG::DataProxy *dp, const CallBackID c, - const IOVSvcCallBackFcn& fcn, bool trigger=false); + const IOVSvcCallBackFcn& fcn, bool trigger=false); StatusCode regFcn(const CallBackID c1, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger); + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger); StatusCode regFcn(const std::string& toolName, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger); + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger); /// Update Range from dB virtual StatusCode setRange(const CLID& clid, const std::string& key, - IOVRange&); + IOVRange&); virtual StatusCode setRange(const CLID& clid, const std::string& key, - IOVRange& io, - const std::string& storeName); + IOVRange& io, + const std::string& storeName); virtual StatusCode getRange(const CLID& clid, const std::string& key, - IOVRange& io) const; + IOVRange& io) const; /// Subscribe method for DataProxy. key StoreGate key virtual StatusCode regProxy( const SG::DataProxy *proxy, - const std::string& key, - const std::string& storeName); + const std::string& key, + const std::string& storeName); /// replace a registered DataProxy with a new version virtual StatusCode replaceProxy( const SG::DataProxy *pOld, - const SG::DataProxy *pNew, - const std::string& storeName); + const SG::DataProxy *pNew, + const std::string& storeName); /// Another way to subscribe virtual StatusCode regProxy( const CLID& clid, const std::string& key, - const std::string& storeName ); + const std::string& storeName ); + + + virtual StatusCode deregProxy( const SG::DataProxy *proxy ); + virtual StatusCode deregProxy( const CLID& clid, const std::string& key ); + + /// Get IOVRange from db for current event virtual StatusCode getRangeFromDB(const CLID& clid, const std::string& key, - IOVRange& range, std::string &tag) const; + IOVRange& range, std::string &tag, + IOpaqueAddress*& ioa) const; /// Get IOVRange from db for a particular event virtual StatusCode getRangeFromDB(const CLID& clid, const std::string& key, - const IOVTime& time, - IOVRange& range, std::string &tag) const; + const IOVTime& time, + IOVRange& range, std::string &tag, + IOpaqueAddress*& ioa) const; /// Set a particular IOVRange in db (and memory) virtual StatusCode setRangeInDB(const CLID& clid, const std::string& key, - const IOVRange& range, - const std::string &tag); + const IOVRange& range, + const std::string &tag); /// supply a list of TADs whose proxies will be preloaded virtual StatusCode preLoadTAD( const SG::TransientAddress *, - const std::string& storeName ); + const std::string& storeName ); /// supply a list of TADs whose data will be preloaded virtual StatusCode preLoadDataTAD( const SG::TransientAddress *, - const std::string& storeName ); + const std::string& storeName ); /// return list of tools (or functions) that have been triggered by key /// will return FAILURE if no tools found, or no key found virtual StatusCode getTriggeredTools(const std::string& key, - std::set<std::string>& tools, - const std::string& storeName); + std::set<std::string>& tools, + const std::string& storeName); virtual void resetAllProxies(); + virtual void ignoreProxy(const CLID& clid, const std::string& key, + const std::string& storeName); + + virtual StatusCode createCondObj(CondContBase*, const DataObjID&, + const EventIDBase&); + + protected: IOVSvc( const std::string& name, ISvcLocator* svc ); @@ -177,7 +194,7 @@ private: bool createIOVTool(const std::string& storeName, IIOVSvcTool*& tool) const; IIOVSvcTool* getTool( const std::string& storeName, - bool createIF=true ) const; + bool createIF=true ) const; IIOVSvcTool* getTool( const CLID& clid, const std::string& key) const; IIOVSvcTool* getTool( const SG::DataProxy* proxy ) const; IIOVSvcTool* getTool( const CallBackID& c1 ) const; @@ -199,6 +216,11 @@ private: ServiceHandle<IToolSvc> p_toolSvc; ServiceHandle<IClassIDSvc> p_CLIDSvc; + ServiceHandle<StoreGateSvc> p_sgs, p_detStore; + ServiceHandle<ICondSvc> p_condSvc; + ServiceHandle<IProxyProviderSvc> p_pps; + + mutable std::recursive_mutex m_lock; }; diff --git a/Control/IOVSvc/IOVSvc/IOVSvcTool.h b/Control/IOVSvc/IOVSvc/IOVSvcTool.h index 0dec8897c4e5fb9a2e2c1fd1a68254bc8d8c5a56..4ce0540f2f2efd072f5f6154bf4202a2e9a21cdc 100644 --- a/Control/IOVSvc/IOVSvc/IOVSvcTool.h +++ b/Control/IOVSvc/IOVSvc/IOVSvcTool.h @@ -38,6 +38,7 @@ #include <set> #include <map> #include <list> +#include <utility> class StoreGateSvc; @@ -58,24 +59,24 @@ namespace SG { class SortTADptr { public: bool operator() ( const SG::TransientAddress*, - const SG::TransientAddress* ) const; + const SG::TransientAddress* ) const; }; class SortDPptr { public: bool operator() ( const SG::DataProxy*, - const SG::DataProxy* ) const; + const SG::DataProxy* ) const; }; class IOVSvcTool: virtual public IIOVSvcTool, - virtual public IIncidentListener, - virtual public AthAlgTool { + virtual public IIncidentListener, + virtual public AthAlgTool { public: IOVSvcTool(const std::string& type, const std::string& name, - const IInterface* parent); + const IInterface* parent); virtual StatusCode initialize(); @@ -95,46 +96,51 @@ public: // register callback functions StatusCode regFcn(SG::DataProxy *dp, const CallBackID c, - const IOVSvcCallBackFcn& fcn, bool trigger = false); + const IOVSvcCallBackFcn& fcn, bool trigger = false); StatusCode regFcn(const CallBackID c1, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger = false); + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger = false); StatusCode regFcn(const IAlgTool* ia, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger = false); + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger = false); // Update Range from dB virtual StatusCode setRange(const CLID& clid, const std::string& key, - IOVRange&); + IOVRange&); virtual StatusCode getRange(const CLID& clid, const std::string& key, - IOVRange& iov) const; + IOVRange& iov) const; // Subscribe method for DataProxy. key StoreGate key virtual StatusCode regProxy( const SG::DataProxy *proxy, - const std::string& key ); + const std::string& key ); // Another way to subscribe virtual StatusCode regProxy( const CLID& clid, const std::string& key ); + virtual StatusCode deregProxy( const SG::DataProxy *proxy ); + virtual StatusCode deregProxy( const CLID& clid, const std::string& key ); + // replace method for DataProxy, to be used when an update is necessary virtual StatusCode replaceProxy( const SG::DataProxy *pOld, - const SG::DataProxy *pNew); + const SG::DataProxy *pNew); // Get IOVRange from db for current event virtual StatusCode getRangeFromDB(const CLID& clid, const std::string& key, - IOVRange& range, std::string &tag) const; + IOVRange& range, std::string &tag, + IOpaqueAddress*& ioa) const; // Get IOVRange from db for a particular event virtual StatusCode getRangeFromDB(const CLID& clid, const std::string& key, - const IOVTime& time, - IOVRange& range, std::string &tag) const; + const IOVTime& time, + IOVRange& range, std::string &tag, + IOpaqueAddress*& ioa) const; // Set a particular IOVRange in db (and memory) virtual StatusCode setRangeInDB(const CLID& clid, const std::string& key, - const IOVRange& range, - const std::string &tag); + const IOVRange& range, + const std::string &tag); // supply a list of TADs whose proxies will be preloaded virtual StatusCode preLoadTAD( const SG::TransientAddress * ); @@ -145,7 +151,7 @@ public: // return list of tools (or functions) that have been triggered by key // will return FAILURE if no tools found, or no key found virtual StatusCode getTriggeredTools(const std::string& key, - std::set<std::string>& tools); + std::set<std::string>& tools); bool holdsProxy( const SG::DataProxy* proxy ) const; bool holdsProxy( const CLID& clid, const std::string& key ) const; @@ -154,6 +160,13 @@ public: virtual void resetAllProxies(); + void ignoreProxy( const CLID& clid, const std::string& key ) { + m_ignoredProxyNames.insert( std::make_pair(clid,key) ); + } + void ignoreProxy(const SG::DataProxy* proxy) { + m_ignoredProxies.insert(proxy); + } + protected: // Destructor. @@ -168,6 +181,7 @@ private: std::string fullProxyName( const SG::TransientAddress* ) const; std::string fullProxyName( const SG::DataProxy* ) const; std::string fullProxyName( const CLID&, const std::string& ) const; + void setRange_impl (const SG::DataProxy* proxy, IOVRange& iovr); std::string m_storeName; @@ -197,6 +211,9 @@ private: std::multimap< const SG::DataProxy*, BFCN* > m_proxyMap; std::multimap< BFCN*, const SG::DataProxy* > m_bfcnMap; + std::set<const SG::DataProxy*> m_ignoredProxies; + std::set< std::pair<CLID, std::string> > m_ignoredProxyNames; + std::map<BFCN*, CallBackID> m_fcnMap; std::map<CallBackID, BFCN*> m_cbidMap; @@ -227,9 +244,9 @@ private: std::string m_checkTrigger; void scanStartSet(startSet &pSet, const std::string &type, - std::set<const SG::DataProxy*, SortDPptr> &proxiesToReset); + std::set<const SG::DataProxy*, SortDPptr> &proxiesToReset); void scanStopSet(stopSet &pSet, const std::string &type, - std::set<const SG::DataProxy*, SortDPptr> &proxiesToReset); + std::set<const SG::DataProxy*, SortDPptr> &proxiesToReset); void PrintStartSet(); void PrintStopSet(); diff --git a/Control/IOVSvc/cmt/requirements b/Control/IOVSvc/cmt/requirements index df2abe145631008ca6d79b91f382ebf42d46ceca..abfb731d5d676af0d93f5139dacfff4b95d895c4 100755 --- a/Control/IOVSvc/cmt/requirements +++ b/Control/IOVSvc/cmt/requirements @@ -9,6 +9,7 @@ use SGTools SGTools-* Control use AthenaKernel AthenaKernel-* Control use AthenaBaseComps AthenaBaseComps-* Control use AtlasBoost AtlasBoost-* External +use StoreGate StoreGate-* Control use GaudiInterface GaudiInterface-* External apply_pattern declare_joboptions files="IOVSvc.txt IOVSvc.py" @@ -17,9 +18,7 @@ apply_pattern dual_use_library files="*.cxx" private -use StoreGate StoreGate-* Control use EventInfo EventInfo-* Event use TestTools TestTools-* AtlasTest apply_pattern UnitTest_run unit_test=IOVSvcTool extrapatterns="^HistogramPersis.* INFO|^IOVSvc +DEBUG|^IOVSvcTool +DEBUG" end_private - diff --git a/Control/IOVSvc/share/IOVSvcTool_test.ref b/Control/IOVSvc/share/IOVSvcTool_test.ref index dece229abc02ce0f3795002235fea914c7cca301..f029510c7c3138a15d37f0d3fbad2b51ede07dd5 100644 --- a/Control/IOVSvc/share/IOVSvcTool_test.ref +++ b/Control/IOVSvc/share/IOVSvcTool_test.ref @@ -10,24 +10,33 @@ JobOptionsSvc INFO Job options successfully read in from ../share/IOVSvcT ApplicationMgr DEBUG Getting my own properties ApplicationMgr SUCCESS ==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v3r1) - running on lxplus0077.cern.ch on Thu Sep 18 19:13:28 2014 + Welcome to ApplicationMgr (GaudiCoreSvc v3r4) + running on lxplus026.cern.ch on Sun Apr 10 21:59:19 2016 ==================================================================================================================================== ApplicationMgr INFO Successfully loaded modules : StoreGate, IOVSvc ApplicationMgr INFO Application Manager Configured successfully ServiceManager DEBUG Initializing service IncidentSvc IncidentSvc DEBUG Service base class initialized successfully ServiceManager DEBUG Initializing service DetectorStore -DetectorStore INFO Initializing DetectorStore - package version StoreGate-02-43-01 +DetectorStore INFO Initializing DetectorStore - package version StoreGate-03-06-37 DetectorStore DEBUG Service base class initialized successfully IncidentSvc DEBUG Adding [EndEvent] listener 'DetectorStore' with priority 100 IncidentSvc DEBUG Adding [BeginEvent] listener 'DetectorStore' with priority 100 EventPersistenc... DEBUG Service base class initialized successfully -ClassIDSvc INFO Initializing ClassIDSvc - package version CLIDComps-00-06-13 +ClassIDSvc INFO Initializing ClassIDSvc - package version CLIDComps-00-06-19 ClassIDSvc DEBUG Service base class initialized successfully IncidentSvc DEBUG Adding [ModuleLoaded] listener 'ClassIDSvc' with priority 100 -ClassIDSvc INFO getRegistryEntries: read 739 CLIDRegistry entries for module ALL -ProxyProviderSvc INFO Initializing ProxyProviderSvc - package version SGComps-00-01-09 +ClassIDSvc INFO getRegistryEntries: read 853 CLIDRegistry entries for module ALL +ClassIDSvc DEBUG processCLIDDB: read 1314 entries from CLIDDB file: /afs/cern.ch/user/s/ssnyder/atlas-work3/InstallArea/share/clid.db +ClassIDSvc DEBUG processCLIDDB: read 1314 entries from CLIDDB file: /afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasOffline/rel_0/InstallArea/share/clid.db +ClassIDSvc DEBUG processCLIDDB: read 1287 entries from CLIDDB file: /afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasAnalysis/rel_0/InstallArea/share/clid.db +ClassIDSvc DEBUG processCLIDDB: read 1122 entries from CLIDDB file: /afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasSimulation/rel_0/InstallArea/share/clid.db +ClassIDSvc DEBUG processCLIDDB: read 1270 entries from CLIDDB file: /afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasTrigger/rel_0/InstallArea/share/clid.db +ClassIDSvc DEBUG processCLIDDB: read 1199 entries from CLIDDB file: /afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasReconstruction/rel_0/InstallArea/share/clid.db +ClassIDSvc DEBUG processCLIDDB: read 1096 entries from CLIDDB file: /afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasEvent/rel_0/InstallArea/share/clid.db +ClassIDSvc DEBUG processCLIDDB: read 261 entries from CLIDDB file: /afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasConditions/rel_0/InstallArea/share/clid.db +ClassIDSvc DEBUG processCLIDDB: read 100 entries from CLIDDB file: /afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasCore/rel_0/InstallArea/share/clid.db +ProxyProviderSvc INFO Initializing ProxyProviderSvc - package version SGComps-00-02-07 ServiceManager DEBUG Initializing service AppMgrRunable AppMgrRunable DEBUG Service base class initialized successfully ServiceManager DEBUG Initializing service EventLoopMgr @@ -43,14 +52,25 @@ HistogramPersis...WARNING Histograms saving not required. ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr Ready ToolSvc DEBUG Service base class initialized successfully -StoreGateSvc INFO Initializing StoreGateSvc - package version StoreGate-02-43-01 +IOVSvc DEBUG Initializing IOVSvc version IOVSvc-00-07-38 +IOVSvc DEBUG AthService initialized +StoreGateSvc INFO Initializing StoreGateSvc - package version StoreGate-03-06-37 StoreGateSvc DEBUG Service base class initialized successfully IncidentSvc DEBUG Adding [EndEvent] listener 'StoreGateSvc' with priority 100 IncidentSvc DEBUG Adding [BeginEvent] listener 'StoreGateSvc' with priority 100 +ConditionStore INFO Initializing ConditionStore - package version StoreGate-03-06-37 +ConditionStore DEBUG Service base class initialized successfully +IncidentSvc DEBUG Adding [EndEvent] listener 'ConditionStore' with priority 100 +IncidentSvc DEBUG Adding [BeginEvent] listener 'ConditionStore' with priority 100 +CondSvc DEBUG db file not set +IOVSvcTool DEBUG Initializing IOVSvcTool version IOVSvc-00-07-38 IncidentSvc DEBUG Adding [BeginEvent] listener 'ToolSvc.IOVSvcTool' with priority 100 IncidentSvc DEBUG Adding [BeginRun] listener 'ToolSvc.IOVSvcTool' with priority 100 IOVSvcTool INFO IOVRanges will be checked at every Event IncidentSvc DEBUG Adding [CheckIOV] listener 'ToolSvc.IOVSvcTool' with priority 100 -ClassIDSvc INFO getRegistryEntries: read 288 CLIDRegistry entries for module ALL -IOVSvcTool DEBUG replace proxy [Dooo:6666/old] @0x2c44a20 with [Dooo:6666/new] @0x2c0b570 +IncidentSvc DEBUG Adding [ReloadProxies] listener 'ToolSvc.IOVSvcTool' with priority 100 +IOVSvcTool DEBUG Tool initialized +ClassIDSvc INFO getRegistryEntries: read 343 CLIDRegistry entries for module ALL +IOVSvcTool DEBUG registering proxy [Dooo:6666/old] at 0x19768a0 +IOVSvcTool DEBUG replace proxy [Dooo:6666/old] @0x19768a0 with [Dooo:6666/new] @0x18c4a10 *** IOVSvcTool_test OK *** diff --git a/Control/IOVSvc/src/CBNode.cxx b/Control/IOVSvc/src/CBNode.cxx index 15b3bc22f568dc7aa11fb834966b8a42cb7390f1..2309b565bffa048ce74678ff8eb7a9d790a512bb 100755 --- a/Control/IOVSvc/src/CBNode.cxx +++ b/Control/IOVSvc/src/CBNode.cxx @@ -15,10 +15,10 @@ *****************************************************************************/ #ifndef IOVSVC_CBNODE_H - #include "IOVSvc/CBNode.h" +#include "IOVSvc/CBNode.h" #endif #ifndef SGTOOLS_DATAPROXY_H - #include "SGTools/DataProxy.h" +#include "SGTools/DataProxy.h" #endif unsigned int CBNode::s_serial = 0; @@ -36,7 +36,7 @@ CBNode::CBNode(std::string name, CBNode* parent): } CBNode::CBNode(const SG::DataProxy* proxy, const std::string& name, - CBNode* parent): + CBNode* parent): m_name(name), m_proxy(proxy), m_fcn(0), m_trig(false), m_flag(false) { m_serial = ++s_serial; addParent( parent ); @@ -75,6 +75,24 @@ void CBNode::addChild( CBNode* child ) { m_children.insert( child ); } +bool CBNode::delParent( CBNode* par ) { + std::set<CBNode*>::iterator itr = m_parents.find(par); + if (itr != m_parents.end()) { + m_parents.erase( itr ); + return true; + } + return false; +} + +bool CBNode::delChild( CBNode* child ) { + std::set<CBNode*>::iterator itr = m_children.find(child); + if (itr != m_children.end()) { + m_children.erase( itr ); + return true; + } + return false; +} + void CBNode::setProxy( const SG::DataProxy* p) { assert(0 != p); m_proxy=p; diff --git a/Control/IOVSvc/src/CBTree.cxx b/Control/IOVSvc/src/CBTree.cxx index eb494ae4aadfd54603332841d2aae5d73e08a15e..4c11b9da135f15c5712e9e9d48ca76935e7adb11 100755 --- a/Control/IOVSvc/src/CBTree.cxx +++ b/Control/IOVSvc/src/CBTree.cxx @@ -15,11 +15,11 @@ *****************************************************************************/ #ifndef IOVSVC_CBTREE_H - #include "IOVSvc/CBTree.h" +#include "IOVSvc/CBTree.h" #endif #ifndef SGTOOLS_DATAPROXY_H - #include "SGTools/DataProxy.h" +#include "SGTools/DataProxy.h" #endif #include <iostream> @@ -80,13 +80,13 @@ CBNode* CBTree::addNode(const std::string& name, CBNode* parent) { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CBNode* CBTree::addNode(BFCN* fcn, const CallBackID& cb, - const SG::DataProxy* proxy) { + const SG::DataProxy* proxy) { CBNode* parent = findNode(proxy); if (parent == 0) { cout << "ERROR: no parent proxy found in tree for " << proxy->name() - << endl; + << endl; return 0; } @@ -104,7 +104,7 @@ CBNode* CBTree::addNode(BFCN* fcn, const CallBackID& cb, BFCN* parent_fcn) { if (parent == 0) { cout << "ERROR: no parent function found in tree for " << parent_fcn - << endl; + << endl; return 0; } @@ -114,6 +114,35 @@ CBNode* CBTree::addNode(BFCN* fcn, const CallBackID& cb, BFCN* parent_fcn) { return n; } +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +bool CBTree::delNode(const SG::DataProxy* prx) { + CBNode *n = findNode(prx); + if (n == 0) { + cout << "ERROR: no node with DataProxy " << prx->name() << " found in tree" + << endl; + return false; + } + + bool b(true); + for ( auto p : n->parents() ) { + if (!p->delChild( n )) { + cout << "ERROR: CBTree::delNode : unable to delete child " + << n->name() << " from parent " << p->name() << endl; + b = false; + } + } + + for (auto c : n->children()) { + if (!c->delParent( n )) { + cout << "ERROR: CBTree::delNode : unable to delete parent " + << n->name() << " from child " << c->name() << endl; + b = false; + } + } + + return b; +} /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -123,8 +152,8 @@ void CBTree::connectNode(CBNode* node, CBNode* parent) { cascadeFlag(true, node); if (parent->flag()) { cout << "ERROR: cannot connect " << node->name() << " to " - << parent->name() << " as a loop would be formed" - << endl; + << parent->name() << " as a loop would be formed" + << endl; return; } clearFlag(); @@ -158,10 +187,23 @@ void CBTree::connectNode(const std::string& name, CBNode* parent) { CBNode* CBTree::findNode(const SG::DataProxy* proxy) const { - std::set<CBNode*>::const_iterator citr = m_root->children().begin(); - for (;citr != m_root->children().end(); ++citr) { - if ( (*citr)->proxy() == proxy ) { - return (*citr); + return findNode(proxy, m_root); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +CBNode* CBTree::findNode(const SG::DataProxy* proxy, CBNode* start) const { + + if ( start->proxy() == proxy ) { + return start; + } else { + + for ( auto c : start->children() ) { + c = findNode(proxy, c); + if (c != 0) { + return c; + } } } @@ -188,7 +230,7 @@ CBNode* CBTree::findNode(BFCN* fcn, CBNode* start) const { for (; citr != start->children().end(); ++citr) { c = findNode(fcn,*citr); if (c != 0) { - return c; + return c; } } } @@ -215,7 +257,7 @@ CBNode* CBTree::findNode(const std::string& name, CBNode* start) const { for (; citr != start->children().end(); ++citr) { c = findNode(name,*citr); if (c != 0) { - return c; + return c; } } } @@ -302,15 +344,15 @@ void CBTree::listNodes() const { nodeSet::const_iterator citr = m_allNodes.begin(); for (; citr != m_allNodes.end(); ++citr) { cout << (*citr)->name() << " " << *citr << " " << (*citr)->level() - << " " << (*citr)->trigger() << endl; + << " " << (*citr)->trigger() << endl; } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CBTree::listNodes(const int& level, - nodeSet::const_iterator& start, - nodeSet::const_iterator& end) const { + nodeSet::const_iterator& start, + nodeSet::const_iterator& end) const { bool s = false; @@ -480,7 +522,7 @@ void CBTree::traverse(void(*pf) (CBNode*,CBNode*)) const { } void CBTree::traverse(CBNode* current, CBNode* parent, - void(*pf) (CBNode*, CBNode*)) const { + void(*pf) (CBNode*, CBNode*)) const { if (current == 0) { return; } @@ -494,7 +536,7 @@ void CBTree::traverse(CBNode* current, CBNode* parent, } void CBTree::traverseR(CBNode* current, CBNode* child, - void(*pf) (CBNode*, CBNode*)) const { + void(*pf) (CBNode*, CBNode*)) const { if (current == 0) { return; } @@ -518,7 +560,6 @@ CBNode* CBTree::traverse(CBNode* (*pf) (CBNode*)) const { } - CBNode* CBTree::traverse(CBNode* current, CBNode* (*pf) (CBNode*)) const { CBNode *n = (*pf)(current); @@ -532,7 +573,7 @@ CBNode* CBTree::traverse(CBNode* current, CBNode* (*pf) (CBNode*)) const { for (; citr != current->children().end(); ++citr) { c = traverse(*citr, pf ); if (c != 0) { - return c; + return c; } } } @@ -554,7 +595,7 @@ CBNode* CBTree::traverseR(CBNode* current, CBNode* (*pf) (CBNode*)) const { for (; citr != current->parents().end(); ++citr) { c = traverseR(*citr, pf ); if (c != 0) { - return c; + return c; } } } diff --git a/Control/IOVSvc/src/CondInputLoader.cxx b/Control/IOVSvc/src/CondInputLoader.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6b06471a8096efeb91aa1d22b984d9417d153875 --- /dev/null +++ b/Control/IOVSvc/src/CondInputLoader.cxx @@ -0,0 +1,277 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// CondInputLoader.cxx +// Implementation file for class CondInputLoader +/////////////////////////////////////////////////////////////////// + +#include "CondInputLoader.h" + +// FrameWork includes +#include "GaudiKernel/Property.h" +#include "AthenaKernel/errorcheck.h" +#include "AthenaKernel/IOVTime.h" +#include "AthenaKernel/IOVRange.h" + + + +/////////////////////////////////////////////////////////////////// +// Public methods: +/////////////////////////////////////////////////////////////////// + +// Constructors +//////////////// +CondInputLoader::CondInputLoader( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::AthAlgorithm( name, pSvcLocator ), m_dump(false), + m_condStore("StoreGateSvc/ConditionStore", name), + m_condSvc("CondSvc",name), + m_IOVSvc("IOVSvc",name) + +{ + // + // Property declaration + // + declareProperty( "Load", m_load)->declareUpdateHandler(&CondInputLoader::loader, this); + declareProperty( "ShowEventDump", m_dump=false); + +} + +// Destructor +/////////////// +CondInputLoader::~CondInputLoader() +{} + +//----------------------------------------------------------------------------- + +// Athena Algorithm's Hooks +//////////////////////////// +StatusCode +CondInputLoader::initialize() +{ + ATH_MSG_INFO ("Initializing " << name() << "..."); + + if (!m_condSvc.isValid()) { + ATH_MSG_ERROR("could not get the CondSvc"); + return StatusCode::FAILURE; + } + + if (!m_condStore.isValid()) { + ATH_MSG_ERROR("could not get the ConditionStore"); + return StatusCode::FAILURE; + } + + StatusCode sc(StatusCode::SUCCESS); + + std::ostringstream str; + str << "Will create WriteCondHandle dependencies for the following DataObjects:"; + for (auto &e : m_load) { + str << "\n + " << e; + if (e.key() == "") { + sc = StatusCode::FAILURE; + str << " ERROR: empty key is not allowed!"; + } else { + Gaudi::DataHandle dh(e, Gaudi::DataHandle::Writer, this); + if (m_condSvc->regHandle(this, dh, e.key()).isFailure()) { + ATH_MSG_ERROR("Unable to register WriteCondHandle " << dh.fullKey()); + sc = StatusCode::FAILURE; + } + // if (m_condSvc->regCondHandle(this, dh, e.key()).isFailure()) { + // ATH_MSG_ERROR("Unable to register managed handle " << dh.fullKey()); + // sc = StatusCode::FAILURE; + // } + m_IOVSvc->ignoreProxy(dh.fullKey().clid(), e.key()); + } + } + + ATH_MSG_INFO(str.str()); + + return sc; +} + +//----------------------------------------------------------------------------- + +StatusCode +CondInputLoader::finalize() +{ + ATH_MSG_INFO ("Finalizing " << name() << "..."); + + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------------------- + +StatusCode +CondInputLoader::execute() +{ + ATH_MSG_DEBUG ("Executing " << name() << "..."); + +#ifdef ATHENAHIVE + + // if (m_first) { + // StatusCode sc(StatusCode::SUCCESS); + // auto managedIDs = m_condSvc->managedIDs(); + // for (auto id : managedIDs) { + // if (m_load.find(id) == m_load.end()) { + // ATH_MSG_ERROR(" not configured to provide WriteCondHandle for " + // << id); + // sc = StatusCode::FAILURE; + // } + // } + + // DataObjIDColl::iterator itr; + // for (itr = m_load.begin(); itr != m_load.end(); ) { + // if ( managedIDs.find( *itr )== managedIDs.end() ) { + // ATH_MSG_DEBUG(" removing ID " << *itr + // << " from Loader list as it's not used"); + // itr = m_load.erase(itr); + // } else { + // ++itr; + // } + // } + + // m_first = false; + + // if (sc.isFailure()) { return sc; } + + // } + + if (m_first) { + DataObjIDColl::iterator itr; + for (itr = m_load.begin(); itr != m_load.end(); ) { + // if ( ! m_condStore->contains(itr->clid(), itr->key() ) ){ + if ( ! m_condStore->contains<CondContBase>( itr->key() ) ){ + ATH_MSG_INFO("ConditionStore does not contain a CondCont<> of " + << *itr + << ". Either a ReadCondHandle was not initailized or " + << "no other Algorithm is using this Handle"); + itr = m_load.erase(itr); + } else { + ++itr; + } + } + m_first = false; + } + + + + + EventIDBase now( getContext()->eventID() ); + IOVTime t(now.run_number(), now.event_number(), now.time_stamp()); + + EventIDRange r; + StatusCode sc; + std::string tag; + // for (auto &obj: extraOutputDeps()) { + for (auto &obj: m_load) { + + ATH_MSG_DEBUG( "handling id: " << obj ); + + CondContBase* ccb(0); + if (! m_condStore->retrieve(ccb, obj.key()).isSuccess()) { + ATH_MSG_ERROR( "unable to get CondContBase* for " << obj + << " from ConditionStore" ); + continue; + } + + + if (ccb->valid(now)) { + ATH_MSG_INFO( " CondObj " << obj << " is still valid at " << now ); + evtStore()->addedNewTransObject(obj.clid(), obj.key()); + continue; + } + + + if (m_IOVSvc->createCondObj( ccb, obj, now ).isFailure()) { + ATH_MSG_ERROR("unable to create Cond object for " << obj); + return StatusCode::FAILURE; + } else { + evtStore()->addedNewTransObject(obj.clid(), obj.key()); + } + + // IOVRange range; + // IOpaqueAddress* ioa; + + // if (m_IOVSvc-> getRangeFromDB(obj.clid(), obj.key(), + // t, range, tag, ioa).isFailure()) { + // ATH_MSG_ERROR( "unable to get range from db for " + // << obj.clid() << " " << obj.key() ); + // continue; + // } + + // ATH_MSG_INFO( " new range: " << range ); + + // if (ccb->proxy() == nullptr) { + // SG::DataProxy *dp = m_condSvc->getProxy( obj ); + // ccb->setProxy(dp); + // } + + // // this will talk to the IOVDbSvc, get current run/event from EventInfo + // // object, load + // SG::DataProxy* dp = ccb->proxy(); + // DataObject* dobj(0); + // void* v(0); + + // if (dp->loader()->createObj(ioa, dobj).isFailure()) { + // ATH_MSG_ERROR(" could not create a new DataObject "); + // } else { + // ATH_MSG_INFO(" created new obj at " << dobj ); + + // v = SG::Storable_cast(dobj, obj.clid()); + + // } + + // // v = SG::DataProxy_cast(ccb->proxy(), obj.clid()); + // DataObject *d2 = static_cast<DataObject*>(v); + + // ATH_MSG_INFO( " obj: " << d2 ); + + // EventIDRange r2(EventIDBase(range.start().run(), range.start().event()), + // EventIDBase(range.stop().run(), range.stop().event())); + + // ccb->insert( r2, d2); + + // ATH_MSG_INFO ("inserted new object at " << d2 ); + + // evtStore()->addedNewTransObject(obj.clid(), obj.key()); + + // ATH_MSG_INFO ("addedNewTransObj"); + + + // SG::DataProxy* dp = evtStore()->proxy(obj.clid(), obj.key()); + // if (dp != 0) { + // ATH_MSG_DEBUG("loading obj " << obj); + // if (dp->transientAddress()->provider() == 0) { + // ATH_MSG_DEBUG(" obj " << obj << " has no provider, and is only Transient" ); + // } + // evtStore()->addedNewTransObject(obj.clid(), obj.key()); + // } else { + // ATH_MSG_ERROR("unable to get proxy for " << obj); + // } + + } + +#endif + + if (m_dump) { + ATH_MSG_DEBUG(evtStore()->dump()); + } + + + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------------------- + +void +CondInputLoader::loader(Property& p ) { + + ATH_MSG_DEBUG("setting prop ExtraOutputs to " << p.toString()); + + if (!setProperty("ExtraOutputs", p).isSuccess()) { + ATH_MSG_WARNING("failed setting property ExtraOutputs"); + } +} diff --git a/Control/IOVSvc/src/CondInputLoader.h b/Control/IOVSvc/src/CondInputLoader.h new file mode 100644 index 0000000000000000000000000000000000000000..2f723bd67b5418b5d7b8cde84cc9c1cf31e3c455 --- /dev/null +++ b/Control/IOVSvc/src/CondInputLoader.h @@ -0,0 +1,87 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// CondInputLoader.h +// Header file for class CondInputLoader +/////////////////////////////////////////////////////////////////// +#ifndef IOVSVC_CONDINPUTLOADER_H +#define IOVSVC_CONDINPUTLOADER_H 1 + +// STL includes +#include <string> + + +#include "GaudiKernel/DataObjID.h" +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/ServiceHandle.h" + +#include "AthenaKernel/IIOVSvc.h" +#include "StoreGate/StoreGateSvc.h" +#include "AthenaBaseComps/AthAlgorithm.h" + + + +class CondInputLoader + : public ::AthAlgorithm +{ + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + + // Copy constructor: + + /// Constructor with parameters: + CondInputLoader( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Destructor: + virtual ~CondInputLoader(); + + // Assignment operator: + //CondInputLoader &operator=(const CondInputLoader &alg); + + // Athena algorithm's Hooks + virtual StatusCode initialize(); + virtual StatusCode execute(); + virtual StatusCode finalize(); + + /////////////////////////////////////////////////////////////////// + // Const methods: + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // Non-const methods: + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // Private data: + /////////////////////////////////////////////////////////////////// + private: + + /// Default constructor: + // CondInputLoader(); + + void loader(Property&); + + /// Containers + DataObjIDColl m_load; + + bool m_dump; +#ifdef ATHENAHIVE + bool m_first { true }; +#endif + + ServiceHandle<StoreGateSvc> m_condStore; + ServiceHandle<ICondSvc> m_condSvc; + ServiceHandle<IIOVSvc> m_IOVSvc; + + + +}; + + +#endif //> !SGCOMPS_SGINPUTLOADER_H diff --git a/Control/IOVSvc/src/CondSvc.cxx b/Control/IOVSvc/src/CondSvc.cxx new file mode 100644 index 0000000000000000000000000000000000000000..20e73e93ff33eda8fe1393a5d0f143adb29a0919 --- /dev/null +++ b/Control/IOVSvc/src/CondSvc.cxx @@ -0,0 +1,465 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "IOVSvc/CondSvc.h" +#include "AthenaKernel/CondCont.h" +#include "GaudiKernel/SvcFactory.h" + +#include <boost/tokenizer.hpp> +#include <boost/algorithm/string.hpp> +#include <boost/regex.hpp> + +#include <fstream> + +// DECLARE_COMPONENT(CondSvc) + +std::string r_t("\\[([0-9]+),([0-9]+)\\]"); +std::string r_r = "\\s*\\{" + r_t + "-" + r_t + "\\}\\s*"; +std::string r_e = "\\s*\\{" + r_t + "-" + r_t + "\\}=([0-9]+)\\s*"; +std::string r_ef = "\\s*\\{" + r_t + "-" + r_t + "\\}=(-*[0-9]*\\.*[0-9]*)\\s*"; +boost::regex rr(r_r); +boost::regex re(r_e); +boost::regex ref(r_ef); + + +//--------------------------------------------------------------------------- + +CondSvc::CondSvc( const std::string& name, ISvcLocator* svcLoc ): + base_class(name,svcLoc), + m_sgs("StoreGateSvc/ConditionStore", name) +{ + + declareProperty("CondFile",m_file=""); + +} + +//--------------------------------------------------------------------------- + +CondSvc::~CondSvc() { + +} + +//--------------------------------------------------------------------------- + +StatusCode +CondSvc::initialize() { + + // Initialise mother class in order to print DEBUG messages during initialize() + StatusCode sc(AthService::initialize()); + msg().setLevel( m_outputLevel.value() ); + + if (!sc.isSuccess()) { + warning () << "Base class could not be initialized" << endmsg; + return StatusCode::FAILURE; + } + + if (!m_sgs.isValid()) { + error() << "could not get ConditionStore" << endmsg; + return StatusCode::FAILURE; + } + + if (m_file == "") { + ATH_MSG_DEBUG("db file not set"); + return StatusCode::SUCCESS; + } + + if (readDbFile(m_file).isFailure()) { + return StatusCode::FAILURE; + } + + std::ostringstream ost; + ost << " Printing CondDB registry"; + for (auto e : m_registry) { + ost << std::endl << " - id: " << e.first << " r:"; + for (auto r : e.second) { + ost << " " << r.range() << " :: " << *r.objPtr(); + } + } + + ATH_MSG_DEBUG( ost.str() ); + + return StatusCode::SUCCESS; + +} +//--------------------------------------------------------------------------- + +StatusCode +CondSvc::readDbFile(const std::string& fname) { + + StatusCode sc(StatusCode::SUCCESS); + + ATH_MSG_DEBUG("reading cond db from \"" << fname << "\""); + + std::ifstream ifs (fname); + std::string line; + if(ifs.is_open()) { + + typedef boost::tokenizer<boost::char_separator<char> > tokenizer; + boost::char_separator<char> sep(" "); + + IOVEntryT<ICondSvc::dbData_t> ie; + + while( getline (ifs, line) ) { + + // ignore anything after a "#" and blank lines + size_t fh = line.find("#"); + if(fh != std::string::npos) + line.erase(fh,line.length()-fh); + if (line.length() == 0) continue; + + tokenizer tokens(line, sep); + auto it = tokens.begin(); + + std::string dbKey = *it; + + ++it; + + while (it != tokens.end()) { + if (parse(ie,*it)) { + m_registry[dbKey].push_back( ie ); + } else { + error() << "while reading " << fname << " problem parsing " << *it + << " in line\n" << line << endmsg; + sc = StatusCode::FAILURE; + } + ++it; + } + } + ifs.close(); + } else { + error() << "unable to open file " << m_file << endmsg; + sc = StatusCode::FAILURE; + } + + return sc; + +} +//--------------------------------------------------------------------------- + +void +CondSvc::dump() const { + + std::lock_guard<std::recursive_mutex> lock(m_lock); + + info() << "CondSvc::dump()"; + + info() << "\ndumping id->alg map\n"; + for (auto ent : m_idMap) { + info() << std::endl << " + " << ent.first << " : "; + for (auto a : ent.second) { + info() << " " << a->name(); + } + } + + info() << "\n\ndumping alg->id map\n"; + for (auto ent : m_algMap) { + info() << std::endl << " + " << ent.first->name() << " : "; + for (auto a : ent.second) { + info() << " " << a; + } + } + + info() << std::endl << endmsg; + +} + +//--------------------------------------------------------------------------- + +StatusCode +CondSvc::finalize() { + + ATH_MSG_DEBUG( "CondSvc::finalize()" ); + + for ( auto e : m_registry ) { + for ( auto ie : e.second ) { + delete ie.objPtr(); + ie.setPtr(0); + } + } + + return StatusCode::SUCCESS; + +} + +//--------------------------------------------------------------------------- + +StatusCode +CondSvc::regHandle(IAlgorithm* alg, const Gaudi::DataHandle& dh, + const std::string& key) { + + std::lock_guard<std::recursive_mutex> lock(m_lock); + + ATH_MSG_DEBUG( "regHandle: alg: " << alg->name() << " id: " << dh.fullKey() + << " dBkey: " << key ); + + if (dh.mode() != Gaudi::DataHandle::Writer) { + info() << dh.fullKey() << " is a ReadHandle. no need to register" + << endmsg; + return StatusCode::SUCCESS; + } + + id_map_t::iterator itd2 = m_idMap.find(dh.fullKey()); + if (itd2 != m_idMap.end()) { + IAlgorithm *ia = *(itd2->second.begin()); + if (ia->name() != alg->name()) { + error() << "WriteCondHandle " << dh.fullKey() + << " is already registered against a different Algorithm " + << ia->name() + << ". This is not allowed." + << endmsg; + return StatusCode::FAILURE; + } + // FIXME : so why is it a set<IAlgorithm*> ?? + } + + m_keyMap[key] = dh.fullKey(); + m_condAlgs.insert(alg); + + // id_map_t::iterator itd2 = m_idMap.find(dh.fullKey()); + if (itd2 != m_idMap.end()) { + itd2->second.insert( alg ); + } else { + m_idMap[dh.fullKey()] = IAlgHashSet { alg }; + } + + alg_map_t::iterator ita2 = m_algMap.find(alg); + if (ita2 != m_algMap.end()) { + ita2->second.insert( dh.fullKey() ); + } else { + m_algMap[alg] = DataObjIDColl { dh.fullKey() }; + } + + return StatusCode::SUCCESS; + +} + +//--------------------------------------------------------------------------- + +bool +CondSvc::getInvalidIDs(const EventContext* ctx, DataObjIDColl& invalidIDs) { + std::lock_guard<std::recursive_mutex> lock(m_lock); + + EventIDBase now(ctx->eventID().run_number(), ctx->eventID().event_number()); + + std::ostringstream ost; + ost << "getInvalidIDS " << ctx->eventID() + << ": retrieving all ConstIterator<CondContBase>"; + SG::ConstIterator<CondContBase> cib, cie; + if (m_sgs->retrieve(cib,cie).isSuccess()) { + while(cib != cie) { + ost << std::endl << " + " << cib.key() << " " << cib->valid(now) + << " id: " << cib->id(); + + if (! (cib->valid(now)) ) { + invalidIDs.insert( cib->id() ); + } + + ++cib; + } + } else { + ATH_MSG_DEBUG(ost.str()); + ATH_MSG_DEBUG("ConditionStore is empty"); + return false; + } + + ost << std::endl << " -> found " << invalidIDs.size() << " invalid IDs"; + + ATH_MSG_DEBUG( ost.str() ); + + return true; +} + +//--------------------------------------------------------------------------- + +bool +CondSvc::getIDValidity(const EventContext* ctx, DataObjIDColl& validIDs, + DataObjIDColl& invalidIDs) { + std::lock_guard<std::recursive_mutex> lock(m_lock); + + EventIDBase now(ctx->eventID()); + + std::ostringstream ost; + ost << "getValidIDS " << ctx->eventID() + << ": retrieving all ConstIterator<CondContBase>"; + SG::ConstIterator<CondContBase> cib, cie; + if (m_sgs->retrieve(cib,cie).isSuccess()) { + while(cib != cie) { + ost << std::endl << " + " << cib.key() << " v: " << cib->valid(now) + << " id: " << cib->id(); + + if ( cib->valid(now) ) { + validIDs.insert( cib->id() ); + } else { + invalidIDs.insert( cib->id() ); + } + + ++cib; + } + } else { + ATH_MSG_DEBUG( ost.str() ); + ATH_MSG_DEBUG( "Condition store empty." ); + return false; + } + + ost << std::endl << " -> found " << validIDs.size() << " valid, " + << invalidIDs.size() << " invalid IDs"; + + ATH_MSG_DEBUG( ost.str() ); + + return true; +} + +//--------------------------------------------------------------------------- + +bool +CondSvc::getValidIDs(const EventContext* ctx, DataObjIDColl& validIDs) { + std::lock_guard<std::recursive_mutex> lock(m_lock); + + EventIDBase now(ctx->eventID()); + + std::ostringstream ost; + ost << "getValidIDS " << ctx->eventID() + << ": retrieving all ConstIterator<CondContBase>"; + SG::ConstIterator<CondContBase> cib, cie; + if (m_sgs->retrieve(cib,cie).isSuccess()) { + while(cib != cie) { + ost << std::endl << " + " << cib.key() << " v: " << cib->valid(now) + << " id: " << cib->id(); + + if ( cib->valid(now) ) { + validIDs.insert( cib->id() ); + } + + ++cib; + } + } else { + ATH_MSG_DEBUG( ost.str() ); + ATH_MSG_DEBUG( "Condition store empty." ); + return false; + } + + ost << std::endl << " -> found " << validIDs.size() << " valid IDs"; + + ATH_MSG_DEBUG( ost.str() ); + + return true; +} + +//--------------------------------------------------------------------------- + +std::set<std::string> +CondSvc::getUnchangedAlgs(const DataObjIDColl& ids) { + std::lock_guard<std::recursive_mutex> lock(m_lock); + + std::ostringstream ost; + ost << "getUnchangedAlgs():"; + + std::set<std::string> algs; + id_map_t::const_iterator itr; + + for (auto id : ids) { + ost << "\n id: " << id; + itr = m_idMap.find(id); + if (itr == m_idMap.end()) { + ost << " does not belong to any Alg!!! this shouldn't happen"; + } else { + ost << " belongs to"; + // loop over all Algs registered to this obj + for (auto alg : itr->second) { + ost << " " << alg->name(); + + // loop over all objs registered against this alg, make sure they + // are ALL unchanged + bool match = true; + alg_map_t::const_iterator itr2 = m_algMap.find(alg); + for (auto id2 : itr2->second) { + if ( ids.find(id2) == ids.end()) { + ost << " but has obj " << id2 << " that is not valid"; + match = false; + } + } + + if (match) { + algs.insert( alg->name() ); + } + } + } + // ost << std::endl; + } + + ATH_MSG_DEBUG( ost.str() ); + + return algs; +} + +//--------------------------------------------------------------------------- + +bool +CondSvc::parse(EventIDRange& t, const std::string& s) { + + boost::smatch m; + boost::regex_match(s,m,rr); + + // for (auto res : m) { + // cout << " - " << res << endl; + // } + + if (m.size() != 5) { return false; } + + t = EventIDRange( EventIDBase(std::stoi(m[1]),std::stoi(m[2])), + EventIDBase(std::stoi(m[3]), std::stoi(m[4]))); + + return true; + +} + +//--------------------------------------------------------------------------- + +bool +CondSvc::parse(IOVEntryT<ICondSvc::dbData_t>& ie, const std::string& s) { + + boost::smatch m; + boost::regex_match(s,m,ref); + + if (m.size() != 6) { return false; } + + ie.setRange( EventIDRange( EventIDBase(std::stoi(m[1]), std::stoi(m[2])), + EventIDBase(std::stoi(m[3]), std::stoi(m[4])) ) ); + + ICondSvc::dbData_t *v = new ICondSvc::dbData_t( std::stof(m[5]) ); + ie.setPtr(v); + + return true; + +} + +//--------------------------------------------------------------------------- + +StatusCode +CondSvc::getRange(const std::string& dbKey , const EventContext* ctx, + EventIDRange& rng, ICondSvc::dbData_t& val) const { + + std::lock_guard<std::recursive_mutex> lock(m_lock); + + registry_t::const_iterator itr = m_registry.find(dbKey); + + if (itr == m_registry.end()) { + error() << "getRange: no dbKey " << dbKey << " found in registry" + << endmsg; + return StatusCode::FAILURE; + } + + for (auto e : itr->second) { + if (e.range().isInRange(EventIDBase(ctx->eventID()))) { + rng = e.range(); + val = *(e.objPtr()); + return StatusCode::SUCCESS; + } + } + + error() << "getRange: no range for Time " << ctx->eventID() + << " found for dbKey " << dbKey << endmsg; + + return StatusCode::FAILURE; +} diff --git a/Control/IOVSvc/src/IOVSvc.cxx b/Control/IOVSvc/src/IOVSvc.cxx index fb952336ba990bc11163bf5e3114baa3d47fbf80..15e10f9e17f4216e8f772a0f85d56d2b1f45a177 100755 --- a/Control/IOVSvc/src/IOVSvc.cxx +++ b/Control/IOVSvc/src/IOVSvc.cxx @@ -24,6 +24,7 @@ #include "AthenaKernel/IClassIDSvc.h" #include "IOVSvc/IIOVSvcTool.h" +#include "GaudiKernel/IConversionSvc.h" using SG::DataProxy; using SG::TransientAddress; @@ -38,7 +39,11 @@ const std::string defaultStore = "StoreGateSvc"; IOVSvc::IOVSvc( const std::string& name, ISvcLocator* svc ) : AthService( name, svc ), p_toolSvc("ToolSvc",name), - p_CLIDSvc("ClassIDSvc",name) + p_CLIDSvc("ClassIDSvc",name), + p_sgs("StoreGateSvc",name), + p_detStore("StoreGateSvc/DetectorStore",name), + p_condSvc("CondSvc",name), + p_pps("ProxyProviderSvc",name) { @@ -66,7 +71,7 @@ StatusCode IOVSvc::initialize() { #ifndef NDEBUG if (msgLvl(MSG::DEBUG)) { msg() << MSG::DEBUG << "Initializing IOVSvc version " - << PACKAGE_VERSION << endreq; + << PACKAGE_VERSION << endreq; } #endif @@ -75,6 +80,27 @@ StatusCode IOVSvc::initialize() { msg() << MSG::DEBUG << "AthService initialized" << endreq; } #endif + + if (!p_sgs.isValid()) { + ATH_MSG_ERROR("could not get the Event Store"); + status = StatusCode::FAILURE; + } + + if (!p_detStore.isValid()) { + ATH_MSG_ERROR("could not get the Detector Store"); + status = StatusCode::FAILURE; + } + + if (!p_condSvc.isValid()) { + ATH_MSG_ERROR("could not get the ConditionSvc"); + status = StatusCode::FAILURE; + } + + if (!p_pps.isValid()) { + ATH_MSG_ERROR("could not get the ProxyProviderSvc"); + status = StatusCode::FAILURE; + } + return status; } @@ -107,15 +133,15 @@ StatusCode IOVSvc::finalize() { StatusCode IOVSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) { - if ( IIOVSvc::interfaceID().versionMatch(riid) ) { - *ppvInterface = (IIOVSvc*)this; - } - else { - // Interface is not directly available: try out a base class - return AthService::queryInterface(riid, ppvInterface); - } - addRef(); - return StatusCode::SUCCESS; + if ( IIOVSvc::interfaceID().versionMatch(riid) ) { + *ppvInterface = (IIOVSvc*)this; + } + else { + // Interface is not directly available: try out a base class + return AthService::queryInterface(riid, ppvInterface); + } + addRef(); + return StatusCode::SUCCESS; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -125,12 +151,12 @@ IOVSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) /// StatusCode IOVSvc::regProxy( const DataProxy *proxy, const std::string& key, - const std::string& storeName ) { + const std::string& storeName ) { IIOVSvcTool *ist = getTool( storeName ); if (ist == 0) { msg() << MSG::ERROR << "regProxy: no IOVSvcTool associated with store \"" - << storeName << "\" and failed to create one" << endreq; + << storeName << "\" and failed to create one" << endreq; return (StatusCode::FAILURE); } @@ -138,16 +164,16 @@ IOVSvc::regProxy( const DataProxy *proxy, const std::string& key, if (ist2 != 0) { if (ist2 != ist) { msg() << MSG::ERROR << "regProxy: when registering proxy for " - << fullProxyName(proxy) << " with store \"" << storeName - << "\", it is already registered with store \"" - << ist2->getStoreName() << "\"" << endreq; + << fullProxyName(proxy) << " with store \"" << storeName + << "\", it is already registered with store \"" + << ist2->getStoreName() << "\"" << endreq; return StatusCode::FAILURE; } else { #ifndef NDEBUG if (msgLvl(MSG::DEBUG)) { - msg() << MSG::DEBUG << "regProxy: proxy for " << fullProxyName(proxy) - << " already registered with store \"" << storeName << "\"" - << endreq; + msg() << MSG::DEBUG << "regProxy: proxy for " << fullProxyName(proxy) + << " already registered with store \"" << storeName << "\"" + << endreq; } #endif return StatusCode::SUCCESS; @@ -165,12 +191,12 @@ IOVSvc::regProxy( const DataProxy *proxy, const std::string& key, /// StatusCode IOVSvc::regProxy( const CLID& clid, const std::string& key, - const std::string& storeName ) { + const std::string& storeName ) { IIOVSvcTool *ist = getTool( storeName ); if (ist == 0) { msg() << MSG::ERROR << "regProxy: no IOVSvcTool associated with store \"" - << storeName << "\" and failed to create one." << endreq; + << storeName << "\" and failed to create one." << endreq; return (StatusCode::FAILURE); } @@ -178,17 +204,17 @@ IOVSvc::regProxy( const CLID& clid, const std::string& key, if (ist2 != 0) { if (ist2 != ist) { msg() << MSG::ERROR << "regProxy: when registering proxy for " - << fullProxyName(clid,key) - << " with store " << storeName - << ", it is already registered with store \"" - << ist2->getStoreName() << "\"" << endreq; + << fullProxyName(clid,key) + << " with store " << storeName + << ", it is already registered with store \"" + << ist2->getStoreName() << "\"" << endreq; return StatusCode::FAILURE; } else { #ifndef NDEBUG if (msgLvl(MSG::DEBUG)) { - msg() << MSG::DEBUG << "regProxy: proxy for " << fullProxyName(clid,key) - << " already registered with store \"" << storeName << "\"" - << endreq; + msg() << MSG::DEBUG << "regProxy: proxy for " << fullProxyName(clid,key) + << " already registered with store \"" << storeName << "\"" + << endreq; } #endif return StatusCode::SUCCESS; @@ -201,12 +227,76 @@ IOVSvc::regProxy( const CLID& clid, const std::string& key, /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/// +/// Deregister a DataProxy with the service +/// +StatusCode +IOVSvc::deregProxy( const DataProxy *proxy ) { + + + IIOVSvcTool *ist = getTool( proxy ); + if (ist == 0) { + msg() << MSG::ERROR << "deregProxy: no IOVSvcTool found for proxy " + << fullProxyName( proxy ) + << endmsg; + return (StatusCode::FAILURE); + } + + return ist->deregProxy( proxy ); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/// +/// Deregister a DataProxy with the service +/// +StatusCode +IOVSvc::deregProxy( const CLID& clid, const std::string& key ) { + + + IIOVSvcTool *ist = getTool( clid, key ); + if (ist == 0) { + msg() << MSG::ERROR << "deregProxy: no IOVSvcTool found for proxy " + << fullProxyName(clid,key) + << endmsg; + return StatusCode::FAILURE; + } + + return ist->deregProxy( clid, key ); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/// +/// ignore proxy +/// +void +IOVSvc::ignoreProxy( const CLID& clid, const std::string& key, + const std::string& storeName ) { + + + IIOVSvcTool *ist = getTool( storeName ); + if (ist == 0) { + msg() << MSG::ERROR << "ignoreProxy: no IOVSvcTool found for store " + << storeName << " and failed to create one" + << endmsg; + return; + } + + return ist->ignoreProxy( clid, key ); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + /// /// Replace a registered DataProxy with a new version /// StatusCode IOVSvc::replaceProxy( const DataProxy* pOld, const DataProxy* pNew, - const std::string& storeName ) { + const std::string& storeName ) { StatusCode sc(StatusCode::FAILURE); IIOVSvcTool *ist = getTool( storeName ); @@ -214,7 +304,7 @@ IOVSvc::replaceProxy( const DataProxy* pOld, const DataProxy* pNew, sc = ist->replaceProxy(pOld, pNew); } else { msg() << MSG::ERROR << "regProxy: no IOVSvcTool associated with store \"" - << storeName << "\" and failed to create one." << endreq; + << storeName << "\" and failed to create one." << endreq; } return sc; } @@ -228,13 +318,13 @@ IOVSvc::replaceProxy( const DataProxy* pOld, const DataProxy* pNew, StatusCode IOVSvc::preLoadTAD( const TransientAddress *tad, - const std::string& storeName ) { + const std::string& storeName ) { IIOVSvcTool *ist = getTool( storeName ); if (ist == 0) { msg() << MSG::ERROR << "preLoadTAD: no IOVSvcTool associated with store \"" - << storeName << "\" and failed to create one." << endreq; + << storeName << "\" and failed to create one." << endreq; return StatusCode::FAILURE; } else { return ist->preLoadTAD( tad ); @@ -249,13 +339,13 @@ IOVSvc::preLoadTAD( const TransientAddress *tad, /// StatusCode IOVSvc::preLoadDataTAD( const TransientAddress *tad, - const std::string& storeName ) { + const std::string& storeName ) { IIOVSvcTool *ist = getTool( storeName ); if (ist == 0) { msg() << MSG::ERROR - << "preLoadDataTAD: no IOVSvcTool associated with store \"" - << storeName << "\" and failed to create one." << endreq; + << "preLoadDataTAD: no IOVSvcTool associated with store \"" + << storeName << "\" and failed to create one." << endreq; return StatusCode::FAILURE; } else { return ist->preLoadDataTAD( tad ); @@ -267,7 +357,7 @@ IOVSvc::preLoadDataTAD( const TransientAddress *tad, StatusCode IOVSvc::setRange(const CLID& clid, const std::string& key, - IOVRange& iovr) { + IOVRange& iovr) { IIOVSvcTool *ist = getTool( clid, key ); if (ist == 0) { @@ -276,16 +366,16 @@ IOVSvc::setRange(const CLID& clid, const std::string& key, // use store names. There should be no default store for setRange msg() << MSG::WARNING << "setRange(CLID,key,range) for unregistered proxies " - << "is deprecated - you need to specify a store! " - << "This will be an ERROR soon!" - << endreq; + << "is deprecated - you need to specify a store! " + << "This will be an ERROR soon!" + << endreq; return setRange(clid,key,iovr, defaultStore ); -// msg() << MSG::ERROR << "setRange: proxy " << fullProxyName(clid, key) -// << " not registered in any store." -// << endreq; -// return StatusCode::FAILURE; + // msg() << MSG::ERROR << "setRange: proxy " << fullProxyName(clid, key) + // << " not registered in any store." + // << endreq; + // return StatusCode::FAILURE; } else { return ist->setRange( clid, key, iovr ); @@ -297,28 +387,28 @@ IOVSvc::setRange(const CLID& clid, const std::string& key, StatusCode IOVSvc::setRange(const CLID& clid, const std::string& key, - IOVRange& iovr, const std::string& storeName) { + IOVRange& iovr, const std::string& storeName) { IIOVSvcTool *ist = getTool( storeName ); if (ist == 0) { msg() << MSG::ERROR << "setRange: no IOVSvcTool assocaited with store \"" - << storeName << "\" and failed to create one." << endreq; + << storeName << "\" and failed to create one." << endreq; return StatusCode::FAILURE; } IIOVSvcTool *ist2 = getTool( clid, key ); if (ist2 == 0) { msg() << MSG::INFO << "setRange: proxy for " << fullProxyName(clid,key) - << " not registered with store \"" << storeName << "\". Doing it now" - << endreq; + << " not registered with store \"" << storeName << "\". Doing it now" + << endreq; if (ist->regProxy(clid, key).isFailure()) { return StatusCode::FAILURE; } } else if (ist2 != ist) { msg() << MSG::INFO << "setRange: when registering proxy (clid: " - << clid << " key: " << key << ") with store \"" << storeName - << "\" --> already registered with store \"" << ist2->getStoreName() - << "\"" << endreq; + << clid << " key: " << key << ") with store \"" << storeName + << "\" --> already registered with store \"" << ist2->getStoreName() + << "\"" << endreq; return StatusCode::FAILURE; } @@ -331,13 +421,13 @@ IOVSvc::setRange(const CLID& clid, const std::string& key, StatusCode IOVSvc::getRange(const CLID& clid, const std::string& key, - IOVRange& iov) const { + IOVRange& iov) const { IIOVSvcTool *ist = getTool( clid, key ); if (ist == 0) { msg() << MSG::ERROR << "getRange: proxy for " << fullProxyName(clid,key) - << " not registered" << endreq; + << " not registered" << endreq; return StatusCode::FAILURE; } else { return ist->getRange( clid, key, iov ); @@ -349,15 +439,15 @@ IOVSvc::getRange(const CLID& clid, const std::string& key, StatusCode IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key, - IOVRange& range, std::string& tag) const { + IOVRange& range, std::string& tag, IOpaqueAddress*& ioa) const { IIOVSvcTool *ist = getTool( clid, key ); if (ist == 0) { msg() << MSG::ERROR << "getRangeFromDB: proxy for " - << fullProxyName(clid,key) << " not registered" << endreq; + << fullProxyName(clid,key) << " not registered" << endreq; return StatusCode::FAILURE; } else { - return ist->getRangeFromDB( clid, key, range, tag ); + return ist->getRangeFromDB( clid, key, range, tag, ioa ); } } @@ -366,16 +456,16 @@ IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key, StatusCode IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key, - const IOVTime& time, IOVRange& range, - std::string& tag) const { + const IOVTime& time, IOVRange& range, + std::string& tag, IOpaqueAddress*& ioa) const { IIOVSvcTool *ist = getTool( clid, key ); if (ist == 0) { msg() << MSG::ERROR << "getRangeFromDB: proxy for " - << fullProxyName(clid, key) << " not registered" << endreq; + << fullProxyName(clid, key) << " not registered" << endreq; return StatusCode::FAILURE; } else { - return ist->getRangeFromDB( clid, key, time, range, tag ); + return ist->getRangeFromDB( clid, key, time, range, tag, ioa ); } } @@ -384,12 +474,12 @@ IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key, StatusCode IOVSvc::setRangeInDB(const CLID& clid, const std::string& key, - const IOVRange& range, const std::string &tag) { + const IOVRange& range, const std::string &tag) { IIOVSvcTool *ist = getTool( clid, key ); if (ist == 0) { msg() << MSG::ERROR << "setRangeInDB: proxy for " - << fullProxyName(clid,key) << " not registered" << endreq; + << fullProxyName(clid,key) << " not registered" << endreq; return StatusCode::FAILURE; } else { return ist->setRangeInDB( clid, key, range, tag ); @@ -401,15 +491,15 @@ IOVSvc::setRangeInDB(const CLID& clid, const std::string& key, StatusCode IOVSvc::regFcn(SG::DataProxy* dp, - const CallBackID c, - const IOVSvcCallBackFcn& fcn, - bool trigger) { + const CallBackID c, + const IOVSvcCallBackFcn& fcn, + bool trigger) { IIOVSvcTool *ist = getTool( dp ); if (ist == 0) { msg() << MSG::ERROR << "regFcn: no IOVSvcTool found containing DataProxy " - << fullProxyName( dp ) - << "-> Need to bind DataHandle first" << endreq; + << fullProxyName( dp ) + << "-> Need to bind DataHandle first" << endreq; return StatusCode::FAILURE; } else { return ist->regFcn( dp, c, fcn, trigger ); @@ -420,14 +510,14 @@ IOVSvc::regFcn(SG::DataProxy* dp, StatusCode IOVSvc::regFcn(const CallBackID c1, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger) { + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger) { if (c1 == c2) { msg() << MSG::ERROR - << "Cannot register 2nd callback function and assocaited" - << " object with itself" << endreq; + << "Cannot register 2nd callback function and assocaited" + << " object with itself" << endreq; return StatusCode::FAILURE; } @@ -435,8 +525,8 @@ IOVSvc::regFcn(const CallBackID c1, IIOVSvcTool *ist = getTool( c1 ); if (ist == 0) { msg() << MSG::ERROR << "CallBack function \"" << c2.name() - << "\" cannot be registered since function \"" << c1.name() - << "\" has not been registered first" << endreq; + << "\" cannot be registered since function \"" << c1.name() + << "\" has not been registered first" << endreq; return StatusCode::FAILURE; } else { return ist->regFcn(c1, c2, fcn2, trigger); @@ -448,14 +538,14 @@ IOVSvc::regFcn(const CallBackID c1, StatusCode IOVSvc::regFcn(const std::string& toolName, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger) { + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger) { IAlgTool *ia; if ( p_toolSvc->retrieveTool(toolName, ia, 0, false).isFailure() ) { msg() << MSG::ERROR << "AlgTool " << toolName << " has not yet been created" - << " and thus cannot be registered" - << endreq; + << " and thus cannot be registered" + << endreq; return StatusCode::FAILURE; } @@ -463,7 +553,7 @@ IOVSvc::regFcn(const std::string& toolName, IIOVSvcTool *ist = getTool( ia ); if (ist == 0) { msg() << MSG::ERROR << "No callback registered with AlgTool " << toolName - << endreq; + << endreq; return StatusCode::FAILURE; } else { return ist->regFcn(ia, c2, fcn2, trigger); @@ -475,14 +565,14 @@ IOVSvc::regFcn(const std::string& toolName, StatusCode IOVSvc::getTriggeredTools(const std::string& key, - std::set<std::string>& tools, - const std::string& storeName) { + std::set<std::string>& tools, + const std::string& storeName) { IIOVSvcTool *ist = getTool( storeName, false ); if (ist == 0) { msg() << MSG::ERROR << "getTriggeredTools: no store \"" << storeName - << "\" associated with any IOVSvcTool" - << endreq; + << "\" associated with any IOVSvcTool" + << endreq; return StatusCode::FAILURE; } else { return ist->getTriggeredTools(key, tools); @@ -496,7 +586,7 @@ IOVSvc::getTriggeredTools(const std::string& key, StatusCode IOVSvc::reinitialize() { - // Set flad to reset all proxies + // Set flad to reset all proxies toolMap::iterator itr = m_toolMap.begin(); for ( ; itr!=m_toolMap.end(); ++itr) { @@ -519,8 +609,8 @@ IOVSvc::createIOVTool( const std::string& storeName ) { #ifndef NDEBUG if (msgLvl(MSG::DEBUG)) { msg() << MSG::DEBUG - << "Creating IOVSvcTool associated with store \"" << store - << "\"" << endreq; + << "Creating IOVSvcTool associated with store \"" << store + << "\"" << endreq; } #endif @@ -529,8 +619,8 @@ IOVSvc::createIOVTool( const std::string& storeName ) { IIOVSvcTool *ist(0); if (p_toolSvc->retrieveTool( "IOVSvcTool/" + store, ist, this ).isFailure()) { msg() << MSG::ERROR - << "Unable to create IOVSvcTool assocaited with store \"" - << store << "\"" << endreq; + << "Unable to create IOVSvcTool assocaited with store \"" + << store << "\"" << endreq; return StatusCode::FAILURE; } else { m_toolMap[ store ] = ist; @@ -539,8 +629,8 @@ IOVSvc::createIOVTool( const std::string& storeName ) { } } else { msg() << MSG::INFO - << "an IOVSvcTool already exists assocaited with store \"" - << store << "\"" << endreq; + << "an IOVSvcTool already exists assocaited with store \"" + << store << "\"" << endreq; return StatusCode::SUCCESS; } @@ -556,8 +646,8 @@ IOVSvc::createIOVTool( const std::string& storeName, IIOVSvcTool*& ist ) const { #ifndef NDEBUG if (msgLvl(MSG::DEBUG)) { msg() << MSG::DEBUG - << "Creating IOVSvcTool associated with store \"" << store - << "\"" << endreq; + << "Creating IOVSvcTool associated with store \"" << store + << "\"" << endreq; } #endif @@ -566,8 +656,8 @@ IOVSvc::createIOVTool( const std::string& storeName, IIOVSvcTool*& ist ) const { if ( itr == m_toolMap.end() ) { if (p_toolSvc->retrieveTool( "IOVSvcTool/"+store, ist, this ).isFailure()) { msg() << MSG::ERROR - << "Unable to create IOVSvcTool assocaited with store \"" - << store << "\"" << endreq; + << "Unable to create IOVSvcTool assocaited with store \"" + << store << "\"" << endreq; return false; } else { m_toolMap[ store ] = ist; @@ -575,8 +665,8 @@ IOVSvc::createIOVTool( const std::string& storeName, IIOVSvcTool*& ist ) const { } } else { msg() << MSG::INFO - << "an IOVSvcTool already exists assocaited with store \"" - << store << "\"" << endreq; + << "an IOVSvcTool already exists assocaited with store \"" + << store << "\"" << endreq; ist = itr->second; } return true; @@ -598,7 +688,7 @@ IOVSvc::getTool( const std::string& storeName, bool createIF ) const { IIOVSvcTool *ist(0); if ( itr == m_toolMap.end() ) { msg() << MSG::INFO << "No IOVSvcTool associated with store \"" << store - << "\"" << endreq; + << "\"" << endreq; if (createIF) createIOVTool(store, ist); @@ -732,9 +822,9 @@ IOVSvc::resetAllProxies() { for (; itr!= m_toolMap.end(); ++itr) { IIOVSvcTool* ist = itr->second; #ifndef NDEBUG - if (msgLvl(MSG::DEBUG)) { + if (msgLvl(MSG::DEBUG)) { msg() << MSG::DEBUG << "resetting all proxies for store \"" - << ist->getStoreName() << "\"" << endreq; + << ist->getStoreName() << "\"" << endreq; } #endif ist->resetAllProxies(); @@ -742,3 +832,86 @@ IOVSvc::resetAllProxies() { } +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +StatusCode +IOVSvc::createCondObj(CondContBase* ccb, const DataObjID& id, + const EventIDBase& now) { + + std::lock_guard<std::recursive_mutex> lock(m_lock); + + ATH_MSG_DEBUG("createCondObj: id: " << id << " t: " << now << " valid: " + << ccb->valid(now)); + + if (ccb->valid(now)) { + if (msgLvl(MSG::DEBUG)) { + EventIDRange r; + ccb->range(now,r); + ATH_MSG_DEBUG( " range " << r << " for " << id + << " is still valid at " << now ); + } + return StatusCode::SUCCESS; + } + + IOVTime t(now.run_number(), now.event_number(), now.time_stamp()); + IOVRange range; + IOpaqueAddress* ioa; + std::string tag; + + if (getRangeFromDB(id.clid(), id.key(), t, range, tag, ioa).isFailure()) { + ATH_MSG_ERROR( "unable to get range from db for " + << id.clid() << " " << id.key() ); + return StatusCode::FAILURE; + } + + ATH_MSG_DEBUG( " new range for ID " << id << " : " << range ); + + if (ccb->proxy() == nullptr) { + // SG::DataProxy *dp = p_condSvc->getProxy( id ); + + SG::DataProxy* dp(0); + SG::DataStore* ds = p_detStore->store(); + dp = p_pps->retrieveProxy(id.clid(), id.key(), *ds); + if (dp == 0) { + ATH_MSG_ERROR ( "Could not get DataProxy from ProxyProviderSvc for " + << id ); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG( " found DataProxy " << dp << " for " << id ); + } + + ccb->setProxy(dp); + + } + + // this will talk to the IOVDbSvc, get current run/event from EventInfo + // object, load + SG::DataProxy* dp = ccb->proxy(); + DataObject* dobj(0); + void* v(0); + + if (dp->loader()->createObj(ioa, dobj).isFailure()) { + ATH_MSG_ERROR(" could not create a new DataObject "); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG(" created new obj at " << dobj ); + + v = SG::Storable_cast(dobj, id.clid()); + } + + // v = SG::DataProxy_cast(ccb->proxy(), id.clid()); + DataObject *d2 = static_cast<DataObject*>(v); + + ATH_MSG_DEBUG( " SG::Storable_cast to obj: " << d2 ); + + EventIDRange r2(EventIDBase(range.start().run(), range.start().event()), + EventIDBase(range.stop().run(), range.stop().event())); + + ccb->insert( r2, d2); + + // p_sgs->addedNewTransObject(id.clid(), id.key()); + // ATH_MSG_DEBUG ("addedNewTransObj"); + + return StatusCode::SUCCESS; + +} diff --git a/Control/IOVSvc/src/IOVSvcTool.cxx b/Control/IOVSvc/src/IOVSvcTool.cxx index 960ad0b0e3683f17f67491baba3bedb61626137c..e0636cd54716102324bfb9378e99c819511c1b27 100644 --- a/Control/IOVSvc/src/IOVSvcTool.cxx +++ b/Control/IOVSvc/src/IOVSvcTool.cxx @@ -60,7 +60,9 @@ std::string toUpper(const std::string& str) { return str2; } -bool m_firstRun(true); +namespace { + bool s_firstRun(true); +} /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -72,7 +74,7 @@ using namespace std; bool SortTADptr::operator() ( const SG::TransientAddress* x, - const SG::TransientAddress* y) const { + const SG::TransientAddress* y) const { if ( x->clID() == y->clID() ) { return ( x->name() < y->name() ); @@ -103,7 +105,7 @@ SortDPptr::operator() (const SG::DataProxy* a, const SG::DataProxy *b) const { IOVSvcTool::IOVSvcTool(const std::string& type, const std::string& name, - const IInterface* parent): + const IInterface* parent): AthAlgTool( type, name, parent ), m_storeName("StoreGateSvc"), m_log(msgSvc(), "IOVSvcTool"), @@ -111,7 +113,10 @@ IOVSvcTool::IOVSvcTool(const std::string& type, const std::string& name, p_cndSvc("DetectorStore",name), p_incSvc("IncidentSvc",name), p_PPSvc("ProxyProviderSvc",name), p_CLIDSvc("ClassIDSvc",name), p_toolSvc("ToolSvc",name), - m_curTime(0), m_first(true), m_checkOnce(false), + m_curTime(0), + p_startSet(nullptr), + p_stopSet(nullptr), + m_first(true), m_checkOnce(false), m_triggered(false), m_firstEventOfRun(false), m_resetAllCallbacks(false) { @@ -151,15 +156,15 @@ IOVSvcTool::~IOVSvcTool() { for (std::map<CallBackID, BFCN*>::iterator i = m_cbidMap.begin(); i != m_cbidMap.end(); ++i) - { - delete i->second; - } + { + delete i->second; + } std::set< const TransientAddress*, SortTADptr >::const_iterator titr; for (titr = m_preLoad.begin(); titr != m_preLoad.end(); ++titr) - { - delete *titr; - } + { + delete *titr; + } delete m_trigTree; @@ -183,7 +188,7 @@ IOVSvcTool::initialize() { IProperty* iovSvcProp = dynamic_cast<IProperty*>( p_iovSvc ); if (iovSvcProp == 0) { m_log << MSG::ERROR << "Unable to dcast the IOVSvc to an IProperty" - << endreq; + << endreq; return StatusCode::FAILURE; } @@ -194,12 +199,12 @@ IOVSvcTool::initialize() { setProperty( iovSvcProp->getProperty("sortKeys") ).ignore(); setProperty( iovSvcProp->getProperty("forceResetAtBeginRun") ).ignore(); setProperty( iovSvcProp->getProperty("OutputLevel") ).ignore(); - m_log.setLevel( outputLevel() ); + m_log.setLevel( msg().level() ); #ifndef NDEBUG if (m_log.level() <= MSG::DEBUG) { m_log << MSG::DEBUG << "Initializing IOVSvcTool version " - << PACKAGE_VERSION << endreq; + << PACKAGE_VERSION << endreq; } #endif @@ -250,7 +255,7 @@ IOVSvcTool::initialize() { m_log << "Event" << endreq; } else { m_log << MSG::FATAL << "jobOption \"updateInterval\" must be one of " - << "\"event\" \"run\" or \"job\"" << endreq; + << "\"event\" \"run\" or \"job\"" << endreq; return StatusCode::FAILURE; } @@ -262,6 +267,9 @@ IOVSvcTool::initialize() { m_log << "IOV Data will be preloaded at the same interval" << endreq; } + // For hybrid MP/MT + p_incSvc->addListener( this, "ReloadProxies", pri, true); + #ifndef NDEBUG if (m_log.level() <= MSG::DEBUG) { m_log << MSG::DEBUG << "Tool initialized" << endreq; @@ -294,6 +302,11 @@ IOVSvcTool::handle(const Incident &inc) { bool first = m_first; + // hybrid MP/MT: need to reload everything after workers fork + if (inc.type() == "ReloadProxies") { + m_resetAllCallbacks = true; + } + // Don't bother doing anything if we're handled the first run, and // preLoadData has been set, or if we only want to check once at the // beginning of the job @@ -301,6 +314,24 @@ IOVSvcTool::handle(const Incident &inc) { return; } + if (m_first) { + for (auto e : m_ignoredProxyNames) { + const DataProxy* proxy = p_cndSvc->proxy(e.first,e.second); + + if (proxy == 0) { + m_log << MSG::ERROR << "ignoreProxy: could not retrieve proxy " + << fullProxyName(e.first,e.second) << " from store" << endreq; + } else { + ignoreProxy( proxy ); + m_log << MSG::DEBUG << "will ignore resetting proxy " + << fullProxyName(proxy) + << endmsg; + } + } + } + + + set< const DataProxy*, SortDPptr > proxiesToReset; if (inc.type() == "BeginRun") { @@ -323,41 +354,41 @@ IOVSvcTool::handle(const Incident &inc) { if (inc.type() == "CheckIOV") { const EventIncident* eventInc = dynamic_cast<const EventIncident*>(&inc); if (eventInc != 0) { - if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << " Got EventInfo object from CheckIOV incident" - << endreq; - } - evt = &eventInc->eventInfo(); + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << " Got EventInfo object from CheckIOV incident" + << endreq; + } + evt = &eventInc->eventInfo(); } else if (p_sgSvc->retrieve(evt).isFailure()) { - m_log << MSG::ERROR << " Unable to get EventInfo from either " - << "EventStore or CheckIOV incident" << endreq; - return; + m_log << MSG::ERROR << " Unable to get EventInfo from either " + << "EventStore or CheckIOV incident" << endreq; + return; } else { - if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << " Got EventInfo object from StoreGate " - << "for CheckIOV incident" - << endreq; - } + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << " Got EventInfo object from StoreGate " + << "for CheckIOV incident" + << endreq; + } } } else { - + if (StatusCode::SUCCESS != p_sgSvc->retrieve(evt)) { - // If EventInfo is not in the event store, check whether it - // has come via the BeginRun incident - const EventIncident* eventInc = dynamic_cast<const EventIncident*>(&inc); - if(!eventInc) { - m_log << MSG::ERROR - << " Unable to get EventInfo from either EventStore or " - << inc.type() << " incident" << endreq; - return; - } else { - evt = &eventInc->eventInfo(); - if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << "Got EventIncident from " << inc.type() - << " incident" << endreq; - } - } + // If EventInfo is not in the event store, check whether it + // has come via the BeginRun incident + const EventIncident* eventInc = dynamic_cast<const EventIncident*>(&inc); + if(!eventInc) { + m_log << MSG::ERROR + << " Unable to get EventInfo from either EventStore or " + << inc.type() << " incident" << endreq; + return; + } else { + evt = &eventInc->eventInfo(); + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "Got EventIncident from " << inc.type() + << " incident" << endreq; + } + } } } @@ -378,21 +409,21 @@ IOVSvcTool::handle(const Incident &inc) { } if (inc.type() == "BeginRun") { - // Signal BeginRun directly to IOVDbSvc - IIOVDbSvc *iovDB = 0; - if (StatusCode::SUCCESS != service("IOVDbSvc", iovDB, false)) { - m_log << MSG::DEBUG << "Unable to get the IOVDbSvc" << endreq; - return; - } - if (StatusCode::SUCCESS != iovDB->signalBeginRun(m_curTime)) { - m_log << MSG::ERROR << "Unable to signal begin run to IOVDbSvc" << endreq; - return; - } - else { - if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << "Signaled begin run to IOVDbSvc " << m_curTime << endreq; - } - } + // Signal BeginRun directly to IOVDbSvc + IIOVDbSvc *iovDB = 0; + if (StatusCode::SUCCESS != service("IOVDbSvc", iovDB, false)) { + m_log << MSG::DEBUG << "Unable to get the IOVDbSvc" << endreq; + return; + } + if (StatusCode::SUCCESS != iovDB->signalBeginRun(m_curTime)) { + m_log << MSG::ERROR << "Unable to signal begin run to IOVDbSvc" << endreq; + return; + } + else { + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "Signaled begin run to IOVDbSvc " << m_curTime << endreq; + } + } } if (m_first) { @@ -400,46 +431,46 @@ IOVSvcTool::handle(const Incident &inc) { std::set< const TransientAddress*, SortTADptr >::const_iterator titr; for (titr = m_preLoad.begin(); titr != m_preLoad.end(); ++titr) { - const TransientAddress *tad = *titr; - StatusCode sc = regProxy(tad->clID(), tad->name()); - if (StatusCode::SUCCESS != sc) { - m_log << MSG::ERROR << "handle: Could not register proxy for " << - fullProxyName(tad->clID(), tad->name()) << endreq; - return; - } + const TransientAddress *tad = *titr; + StatusCode sc = regProxy(tad->clID(), tad->name()); + if (StatusCode::SUCCESS != sc) { + m_log << MSG::ERROR << "handle: Could not register proxy for " << + fullProxyName(tad->clID(), tad->name()) << endreq; + return; + } } if (m_log.level() <= MSG::VERBOSE) { - m_log << MSG::VERBOSE; - PrintProxyMap(); - m_log << endreq; + m_log << MSG::VERBOSE; + PrintProxyMap(); + m_log << endreq; } if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << "Callback Tree:" << endreq; - m_trigTree->printTree(); + m_log << MSG::DEBUG << "Callback Tree:" << endreq; + m_trigTree->printTree(); } // preLoad the ranges and data if requested. if (preLoadProxies().isFailure()) { - m_log << MSG::ERROR << "Problems preloading IOVRanges" << endreq; - throw( std::runtime_error("IOVSvcTool::preLoadProxies") ); + m_log << MSG::ERROR << "Problems preloading IOVRanges" << endreq; + throw( std::runtime_error("IOVSvcTool::preLoadProxies") ); } // Signal EndProxyPreload directly to IOVDbSvc IIOVDbSvc *iovDB = 0; if (StatusCode::SUCCESS == service("IOVDbSvc", iovDB, false)) { iovDB->signalEndProxyPreload(); - if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << "Signaled end proxy preload to IOVDbSvc " - << m_curTime << endreq; - } + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "Signaled end proxy preload to IOVDbSvc " + << m_curTime << endreq; + } } } // If preLoadData has been set, never check validity of data again. if (m_preLoadData && m_checkOnce) { - return; + return; } // Otherwise, do the normal check for validity @@ -459,17 +490,17 @@ IOVSvcTool::handle(const Incident &inc) { ////// We need to check both R/E and Clocktime sets // - if (inc.type() == "BeginRun" && m_forceReset && !m_firstRun) { + if (inc.type() == "BeginRun" && m_forceReset && !s_firstRun) { if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG - << "Resetting all proxies on BeginRun incident for store \"" - << m_storeName << "\"" << endreq; - m_log << MSG::VERBOSE; - std::set< const SG::DataProxy* >::const_iterator pit; - for (pit = m_proxies.begin(); pit != m_proxies.end(); ++pit) { - m_log << " " << m_names[*pit] << std::endl; - } - m_log << endreq; + m_log << MSG::DEBUG + << "Resetting all proxies on BeginRun incident for store \"" + << m_storeName << "\"" << endreq; + m_log << MSG::VERBOSE; + std::set< const SG::DataProxy* >::const_iterator pit; + for (pit = m_proxies.begin(); pit != m_proxies.end(); ++pit) { + m_log << " " << m_names[*pit] << std::endl; + } + m_log << endreq; } proxiesToReset = m_proxies; m_triggered = false; @@ -481,6 +512,13 @@ IOVSvcTool::handle(const Incident &inc) { scanStopSet(m_stopSet_RE,"(R/E)",proxiesToReset); } + for (auto p : m_ignoredProxies) { + auto itr = proxiesToReset.find(p); + if (itr != proxiesToReset.end()) { + proxiesToReset.erase( itr ); + } + } + // //// Reset DataProxies, and call associated callback functions //// @@ -489,8 +527,8 @@ IOVSvcTool::handle(const Incident &inc) { for (itr=proxiesToReset.begin(); itr!=proxiesToReset.end(); ++itr) { DataProxy *prx = const_cast<DataProxy*>( *itr ); if (m_log.level() <= MSG::VERBOSE) { - m_log << MSG::VERBOSE << "clearing proxy payload for " << m_names[prx] - << endreq; + m_log << MSG::VERBOSE << "clearing proxy payload for " << m_names[prx] + << endreq; } // Reset proxy except when one wants to reset callbacks @@ -502,29 +540,29 @@ IOVSvcTool::handle(const Incident &inc) { // Load data if preload requested. if ( (m_partialPreLoadData && - m_partPreLoad.find(prx->transientAddress()) != m_partPreLoad.end()) - || - m_preLoadData ) { - if (m_log.level() <= MSG::VERBOSE) { - m_log << MSG::VERBOSE << "preloading data" << endreq; - } + m_partPreLoad.find(prx->transientAddress()) != m_partPreLoad.end()) + || + m_preLoadData ) { + if (m_log.level() <= MSG::VERBOSE) { + m_log << MSG::VERBOSE << "preloading data" << endreq; + } Gaudi::Guards::AuditorGuard auditor(m_names[prx], auditorSvc(), "preLoadProxy"); - if (prx->accessData() == 0) { - m_log << MSG::ERROR << "problems preloading data for " - << m_names[prx] << endreq; - } + if (prx->accessData() == 0) { + m_log << MSG::ERROR << "problems preloading data for " + << m_names[prx] << endreq; + } } std::list<std::string> keys; pair<pmITR,pmITR> fitr = m_proxyMap.equal_range( prx ); for (pmITR p=fitr.first; p!=fitr.second; ++p) { - BFCN *f = p->second; - std::string key = prx->name(); - if (resetKeys.find(f) == resetKeys.end()) { - resetKeys[f] = std::list<std::string>(); - } - resetKeys[f].push_back(key); + BFCN *f = p->second; + std::string key = prx->name(); + if (resetKeys.find(f) == resetKeys.end()) { + resetKeys[f] = std::list<std::string>(); + } + resetKeys[f].push_back(key); } } @@ -537,31 +575,30 @@ IOVSvcTool::handle(const Incident &inc) { if (! (first && m_triggered) ) { for (int i=2; i<= m_trigTree->maxLevel(); ++i) { - CBTree::nodeSet::const_iterator itt, itt_s, itt_e; - m_trigTree->listNodes( i, itt_s, itt_e ); - for (itt = itt_s; itt != itt_e; ++itt) { - CBNode* node = *itt; - - if (node->trigger()) { - BFCN *ff = node->fcn(); - auditorSvc()->before("Callback",m_fcnMap[ff].name()); - if ((*ff)(i,resetKeys[ff]).isFailure()) { - auditorSvc()->after("Callback",m_fcnMap[ff].name()); - m_log << MSG::ERROR << "Problems calling " << m_fcnMap[ff].name() - << std::endl << "Skipping all subsequent callbacks." - << endreq; - // this will cause a mem leak, but I don't care - perr = new IOVCallbackError(m_fcnMap[ff].name()); - break; - } - auditorSvc()->after("Callback",m_fcnMap[ff].name()); - - } - } + CBTree::nodeSet::const_iterator itt, itt_s, itt_e; + m_trigTree->listNodes( i, itt_s, itt_e ); + for (itt = itt_s; itt != itt_e; ++itt) { + CBNode* node = *itt; + + if (node->trigger()) { + BFCN *ff = node->fcn(); + auditorSvc()->before("Callback",m_fcnMap[ff].name()); + if ((*ff)(i,resetKeys[ff]).isFailure()) { + auditorSvc()->after("Callback",m_fcnMap[ff].name()); + m_log << MSG::ERROR << "Problems calling " << m_fcnMap[ff].name() + << std::endl << "Skipping all subsequent callbacks." + << endreq; + // this will cause a mem leak, but I don't care + perr = new IOVCallbackError(m_fcnMap[ff].name()); + break; } + auditorSvc()->after("Callback",m_fcnMap[ff].name()); + + } + } if (perr != 0) break; } } - + /// Clear trigger tree m_trigTree->clearTrigger(); @@ -572,9 +609,9 @@ IOVSvcTool::handle(const Incident &inc) { /// return - no proxies reset and don't need to read in new ranges /// if (m_resetAllCallbacks) { - m_resetAllCallbacks = false; - if (perr != 0) throw (*perr); - return; + m_resetAllCallbacks = false; + if (perr != 0) throw (*perr); + return; } @@ -585,31 +622,31 @@ IOVSvcTool::handle(const Incident &inc) { pitr = m_entries.find( prx ); if ( pitr != m_entries.end() && pitr->second->range()->isInRange(m_curTime) ) { - if (m_log.level() <= MSG::VERBOSE) { - m_log << MSG::VERBOSE << "range still valid for " << m_names[prx] - << endreq; - } + if (m_log.level() <= MSG::VERBOSE) { + m_log << MSG::VERBOSE << "range still valid for " << m_names[prx] + << endreq; + } } else { - if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << "calling provider()->udpateAddress(TAD) for " - << m_names[prx] << endreq; - } - StatusCode sc = prx->transientAddress()->provider()->updateAddress(prx->transientAddress()->storeID(), prx->transientAddress()); - if (StatusCode::SUCCESS != sc) { - m_log << MSG::ERROR << "handle: Could not update address" << endreq; - if (perr != 0) throw (*perr); - return; - } + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "calling provider()->udpateAddress(TAD) for " + << m_names[prx] << endreq; + } + StatusCode sc = prx->transientAddress()->provider()->updateAddress(prx->transientAddress()->storeID(), prx->transientAddress()); + if (StatusCode::SUCCESS != sc) { + m_log << MSG::ERROR << "handle: Could not update address" << endreq; + if (perr != 0) throw (*perr); + return; + } } if (m_log.level() <= MSG::VERBOSE) { - IOpaqueAddress *ioa = prx->transientAddress()->address(); - // Print out some debug info if this is an IOVAddress (coming - // from IOVASCIIDbSvc) - IOVAddress *iova = dynamic_cast<IOVAddress*>(ioa); - if (iova != 0) { - m_log << MSG::VERBOSE << " range: " << iova->range() << endreq; - } + IOpaqueAddress *ioa = prx->transientAddress()->address(); + // Print out some debug info if this is an IOVAddress (coming + // from IOVASCIIDbSvc) + IOVAddress *iova = dynamic_cast<IOVAddress*>(ioa); + if (iova != 0) { + m_log << MSG::VERBOSE << " range: " << iova->range() << endreq; + } } } @@ -619,7 +656,7 @@ IOVSvcTool::handle(const Incident &inc) { } // end if(inc.type() == m_checkTrigger) if ( inc.type() == "BeginRun") { - m_firstRun = false; + s_firstRun = false; } } @@ -641,7 +678,7 @@ IOVSvcTool::regProxy( const DataProxy *proxy, const std::string& key) { #ifndef NDEBUG if (m_log.level() <= MSG::DEBUG) { m_log << MSG::DEBUG << "registering proxy " << fullProxyName(proxy) - << " at " << proxy << endreq; + << " at " << proxy << endreq; } #endif @@ -649,8 +686,8 @@ IOVSvcTool::regProxy( const DataProxy *proxy, const std::string& key) { #ifndef NDEBUG if (m_log.level() <= MSG::DEBUG) { m_log << MSG::DEBUG << "Proxy for " << fullProxyName(proxy) - << " already registered: " << proxy->name() - << endreq; + << " already registered: " << proxy->name() + << endreq; } #endif return StatusCode::SUCCESS; @@ -673,25 +710,85 @@ IOVSvcTool::regProxy( const DataProxy *proxy, const std::string& key) { return StatusCode::SUCCESS; } + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/// +/// Deregister a DataProxy with the service +/// +StatusCode +IOVSvcTool::deregProxy( const DataProxy *proxy) { + + + if (proxy == 0) { + m_log << MSG::ERROR << "proxy == 0" << endreq; + return StatusCode::FAILURE; + } + +#ifndef NDEBUG + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "removing proxy " << fullProxyName(proxy) + << " at " << proxy << endreq; + } +#endif + + std::set<const SG::DataProxy*, SortDPptr>::iterator itr = m_proxies.find(proxy); + if (itr == m_proxies.end()) { +#ifndef NDEBUG + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "Proxy for " << fullProxyName(proxy) + << " not registered: " << proxy->name() + << endreq; + } +#endif + return StatusCode::SUCCESS; + } + + m_proxies.erase( itr ); + + m_trigTree->delNode(proxy); + + return StatusCode::SUCCESS; + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +namespace { + + template <class SET> + void removeFromSet (IOVEntry* ent, SET& set) + { + typename SET::iterator it; + while ((it = set.find(ent)) != set.end()) + set.erase (it); + } + + +} // anonymous namespace + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + /// /// replace a registered DataProxy with a new version /// StatusCode IOVSvcTool::replaceProxy( const SG::DataProxy *pOld, - const SG::DataProxy *pNew) { + const SG::DataProxy *pNew) { assert(0 != pOld); assert(0 != pNew); if (m_log.level() <= MSG::DEBUG) { m_log << MSG::DEBUG << "replace proxy " << fullProxyName(pOld) - << " @" << pOld << " with " << fullProxyName(pNew) - << " @" << pNew << endreq; + << " @" << pOld << " with " << fullProxyName(pNew) + << " @" << pNew << endreq; } //start with the proxy list if (0 == m_proxies.erase(pOld)) { m_log << MSG::DEBUG << "unregProxy: original proxy " - << fullProxyName(pOld) << " not found. Will return now " << endreq; + << fullProxyName(pOld) << " not found. Will return now " << endreq; return StatusCode::SUCCESS; } m_proxies.insert(pNew); @@ -703,9 +800,25 @@ IOVSvcTool::replaceProxy( const SG::DataProxy *pOld, return StatusCode::FAILURE; } m_names[pNew]=tname + "[" + pNew->name() + "]"; + + if (pOld != pNew) { + std::map< const SG::DataProxy*, IOVEntry*>::iterator ent = + m_entries.find(pOld); + if (ent != m_entries.end()) { + removeFromSet (ent->second, m_startSet_Clock); + removeFromSet (ent->second, m_startSet_RE); + removeFromSet (ent->second, m_stopSet_Clock); + removeFromSet (ent->second, m_stopSet_RE); + + setRange_impl (pNew, *ent->second->range()); + delete ent->second; + m_entries.erase (ent); + } + } + return (m_trigTree->replaceProxy(pOld, pNew) ? - StatusCode::SUCCESS : - StatusCode::FAILURE ); + StatusCode::SUCCESS : + StatusCode::FAILURE ); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -720,7 +833,7 @@ IOVSvcTool::regProxy( const CLID& clid, const std::string& key ) { if (proxy == 0) { m_log << MSG::ERROR << "regProxy could not retrieve proxy " - << fullProxyName(clid,key) << " from store" << endreq; + << fullProxyName(clid,key) << " from store" << endreq; return StatusCode::FAILURE; } @@ -730,6 +843,26 @@ IOVSvcTool::regProxy( const CLID& clid, const std::string& key ) { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/// +/// Deregister a DataProxy with the service +/// +StatusCode +IOVSvcTool::deregProxy( const CLID& clid, const std::string& key ) { + + const DataProxy* proxy = p_cndSvc->proxy(clid,key); + + if (proxy == 0) { + m_log << MSG::ERROR << "regProxy could not retrieve proxy " + << fullProxyName(clid,key) << " from store" << endreq; + return StatusCode::FAILURE; + } + + return ( deregProxy(proxy) ); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + /// /// add to a set of TADs that will be registered at start of first event /// @@ -739,16 +872,16 @@ IOVSvcTool::preLoadTAD( const TransientAddress *tad_in ) { // check to see if it's a duplicate in preLoad if (m_preLoad.find( tad_in ) != m_preLoad.end()) { m_log << MSG::WARNING << "preLoadTAD: TransientAddress (" - << tad_in->clID() << "/" << tad_in->name() - << ") alread in preLoad set. Not inserting" << endreq; + << tad_in->clID() << "/" << tad_in->name() + << ") alread in preLoad set. Not inserting" << endreq; return StatusCode::SUCCESS; } // check to see if it's a duplicate in partPreLoad if (m_partPreLoad.find( tad_in ) != m_partPreLoad.end()) { m_log << MSG::WARNING << "preLoadTAD: TransientAddress (" - << tad_in->clID() << "/" << tad_in->name() - << ") alread in partPreLoad set. Not inserting" << endreq; + << tad_in->clID() << "/" << tad_in->name() + << ") alread in partPreLoad set. Not inserting" << endreq; return StatusCode::SUCCESS; } @@ -768,15 +901,15 @@ IOVSvcTool::preLoadDataTAD( const TransientAddress *tad_in ) { if (m_preLoad.find(tad_in) != m_preLoad.end()) { m_log << MSG::WARNING << "preLoadDataTAD: TransientAddress " - << fullProxyName( tad_in ) - << " alread in preLoad set. Not inserting" << endreq; + << fullProxyName( tad_in ) + << " alread in preLoad set. Not inserting" << endreq; return StatusCode::SUCCESS; } if (m_partPreLoad.find(tad_in) != m_partPreLoad.end()) { m_log << MSG::WARNING << "preLoadDataTAD: TransientAddress " - << fullProxyName( tad_in ) - << " alread in partPreLoad set. Not inserting" << endreq; + << fullProxyName( tad_in ) + << " alread in partPreLoad set. Not inserting" << endreq; return StatusCode::SUCCESS; } @@ -789,28 +922,8 @@ IOVSvcTool::preLoadDataTAD( const TransientAddress *tad_in ) { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -StatusCode -IOVSvcTool::setRange(const CLID& clid, const std::string& key, - IOVRange& iovr) { - -#ifndef NDEBUG - if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << "setRange() for clid: " << clid << " key: " << key - << " in IOVrange:" << iovr << endreq; - } -#endif - - if (!iovr.start().isValid() || !iovr.stop().isValid()) { - m_log << MSG::ERROR << "IOVRange " << iovr << "is not valid. Start OK: " - << iovr.start().isValid() << " Stop OK: " << iovr.stop().isValid() - << " run/evt/time min/max " - << IOVTime::MINRUN << "/" << IOVTime::MAXRUN << " " - << IOVTime::MINEVENT << "/" << IOVTime::MAXEVENT << " " - << IOVTime::MINTIMESTAMP << "/" << IOVTime::MAXTIMESTAMP << " " - << endreq; - return StatusCode::FAILURE; - } - +void IOVSvcTool::setRange_impl (const SG::DataProxy* proxy, IOVRange& iovr) +{ if (iovr.start().isTimestamp()) { p_startSet = &m_startSet_Clock; p_stopSet = &m_stopSet_Clock; @@ -819,14 +932,6 @@ IOVSvcTool::setRange(const CLID& clid, const std::string& key, p_stopSet = &m_stopSet_RE; } - DataProxy* proxy = p_cndSvc->proxy(clid,key); - - if (proxy == 0) { - m_log << MSG::ERROR << "setRange: Could not locate proxy for " - << fullProxyName(clid,key) << endreq; - return StatusCode::FAILURE; - } - IOVRange *range = new IOVRange(iovr); map<const DataProxy*, IOVEntry*>::iterator itr = m_entries.find(proxy); @@ -839,11 +944,11 @@ IOVSvcTool::setRange(const CLID& clid, const std::string& key, if (*irn == iovr) { #ifndef NDEBUG if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << "Range has not changed. Returning" << endreq; + m_log << MSG::DEBUG << "Range has not changed. Returning" << endreq; } #endif delete range; - return StatusCode::SUCCESS; + return; // is this true? still in the start and stop sets? FIXME } @@ -874,20 +979,51 @@ IOVSvcTool::setRange(const CLID& clid, const std::string& key, ent->setStartITR( p_startSet->insert( ent ) ); ent->setStopITR( p_stopSet->insert( ent ) ); +} - return StatusCode::SUCCESS; +StatusCode +IOVSvcTool::setRange(const CLID& clid, const std::string& key, + IOVRange& iovr) +{ + +#ifndef NDEBUG + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "setRange() for clid: " << clid << " key: " << key + << " in IOVrange:" << iovr << endreq; + } +#endif + + if (!iovr.start().isValid() || !iovr.stop().isValid()) { + m_log << MSG::ERROR << "IOVRange " << iovr << "is not valid. Start OK: " + << iovr.start().isValid() << " Stop OK: " << iovr.stop().isValid() + << " run/evt/time min/max " + << IOVTime::MINRUN << "/" << IOVTime::MAXRUN << " " + << IOVTime::MINEVENT << "/" << IOVTime::MAXEVENT << " " + << IOVTime::MINTIMESTAMP << "/" << IOVTime::MAXTIMESTAMP << " " + << endreq; + return StatusCode::FAILURE; + } + + DataProxy* proxy = p_cndSvc->proxy(clid,key); + + if (proxy == 0) { + m_log << MSG::ERROR << "setRange: Could not locate proxy for " + << fullProxyName(clid,key) << endreq; + return StatusCode::FAILURE; + } + setRange_impl (proxy, iovr); + return StatusCode::SUCCESS; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ StatusCode IOVSvcTool::getRange(const CLID& clid, const std::string& key, - IOVRange& iov) const { + IOVRange& iov) const { DataProxy* dp = p_cndSvc->proxy(clid,key); - std::map<const DataProxy*,IOVEntry*>::const_iterator itr(m_entries.find(dp)); if (itr == m_entries.end()) { return StatusCode::FAILURE; @@ -897,17 +1033,17 @@ IOVSvcTool::getRange(const CLID& clid, const std::string& key, return StatusCode::SUCCESS; - } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ StatusCode IOVSvcTool::getRangeFromDB(const CLID& clid, const std::string& key, - IOVRange& range, std::string &tag) const { + IOVRange& range, std::string &tag, + IOpaqueAddress*& ioa) const { if (m_curTime.isValid()) { - return getRangeFromDB(clid, key, m_curTime, range, tag); + return getRangeFromDB(clid, key, m_curTime, range, tag, ioa); } else { m_log << MSG::ERROR << "Current Event not defined" << endreq; return StatusCode::FAILURE; @@ -919,21 +1055,21 @@ IOVSvcTool::getRangeFromDB(const CLID& clid, const std::string& key, StatusCode IOVSvcTool::getRangeFromDB(const CLID& clid, const std::string& key, - const IOVTime& time, IOVRange& range, - std::string& tag) const { + const IOVTime& time, IOVRange& range, + std::string& tag, IOpaqueAddress*& ioa) const { StatusCode sc(StatusCode::FAILURE); DataProxy* dp = p_cndSvc->proxy(clid,key); if (0 != dp) { IIOVDbSvc *idb = dynamic_cast<IIOVDbSvc*>(dp->transientAddress()->provider()); if (idb != 0) { - sc = idb->getRange(clid, key, time, range, tag); + sc = idb->getRange(clid, key, time, range, tag, ioa); } else { m_log << MSG::ERROR << "Provider is not an IIOVDbSvc" << endreq; } } else { m_log << MSG::ERROR << "No proxy found for clid " << clid - << " key " << key << endreq; + << " key " << key << endreq; } return sc; } @@ -942,7 +1078,7 @@ IOVSvcTool::getRangeFromDB(const CLID& clid, const std::string& key, StatusCode IOVSvcTool::setRangeInDB(const CLID& clid, const std::string& key, - const IOVRange& range, const std::string &tag) { + const IOVRange& range, const std::string &tag) { if (!range.start().isValid() || !range.stop().isValid()) { @@ -954,14 +1090,14 @@ IOVSvcTool::setRangeInDB(const CLID& clid, const std::string& key, if (dp == 0) { m_log << MSG::ERROR << "no Proxy found for " - << fullProxyName( clid, key ) << endreq; + << fullProxyName( clid, key ) << endreq; return StatusCode::FAILURE; } std::map<const DataProxy*,IOVEntry*>::const_iterator itr(m_entries.find(dp)); if (itr == m_entries.end()) { m_log << MSG::WARNING << fullProxyName(clid,key) - << " not registered with the IOVSvc" << endreq; + << " not registered with the IOVSvc" << endreq; } IAddressProvider *iadp = dp->transientAddress()->provider(); @@ -998,12 +1134,12 @@ IOVSvcTool::preLoadProxies() { m_log << MSG::VERBOSE; m_log.setColor(MSG::CYAN); m_log << "loading proxy for CLID: " << dp->transientAddress()->clID() - << " " << m_names[dp] << endreq; + << " " << m_names[dp] << endreq; } if (dp->transientAddress() == 0 || dp->transientAddress()->provider() == 0) { m_log << MSG::FATAL << "No provider found for proxy " << m_names[dp] - << ". It is probably not a conditions object" << endl; + << ". It is probably not a conditions object" << endl; m_log << "Proxy Map: "; PrintProxyMap(dp); m_log << endreq; @@ -1018,22 +1154,22 @@ IOVSvcTool::preLoadProxies() { pair<pmITR,pmITR> pi = m_proxyMap.equal_range(dp); if (pi.first != pi.second || m_preLoadRanges) { if (m_log.level() <= MSG::VERBOSE) { - m_log << MSG::VERBOSE << "updating Range" << endreq; + m_log << MSG::VERBOSE << "updating Range" << endreq; } sc = dp->transientAddress()->provider()->updateAddress(dp->transientAddress()->storeID(), dp->transientAddress()); } if ( ( m_partialPreLoadData && - m_partPreLoad.find(dp->transientAddress()) != m_partPreLoad.end() ) - || - m_preLoadData ) { + m_partPreLoad.find(dp->transientAddress()) != m_partPreLoad.end() ) + || + m_preLoadData ) { if (m_log.level() <= MSG::VERBOSE) { - m_log << MSG::VERBOSE << "preloading data for (" - << dp->transientAddress()->clID() << "/" - << dp->transientAddress()->name() << ")" << endreq; + m_log << MSG::VERBOSE << "preloading data for (" + << dp->transientAddress()->clID() << "/" + << dp->transientAddress()->name() << ")" << endreq; } sc = ( dp->accessData() != 0 ? - StatusCode::SUCCESS : StatusCode::FAILURE ); + StatusCode::SUCCESS : StatusCode::FAILURE ); } if (sc.isFailure()) scr=sc; @@ -1045,7 +1181,7 @@ IOVSvcTool::preLoadProxies() { BFCN *f = pitr->second; std::string key = dp->name(); if (resetKeys.find(f) == resetKeys.end()) { - resetKeys[f] = std::list<std::string>(); + resetKeys[f] = std::list<std::string>(); } resetKeys[f].push_back(key); } @@ -1059,7 +1195,7 @@ IOVSvcTool::preLoadProxies() { if (scr.isFailure()) { m_log << MSG::ERROR << "Problems preLoading proxies. No callbacks triggered." - << endreq; + << endreq; return scr; } @@ -1071,16 +1207,16 @@ IOVSvcTool::preLoadProxies() { CBNode* node = *itt; if (node->trigger()) { - BFCN *ff = node->fcn(); - if (m_sortKeys) { resetKeys[ff].sort(); } - auditorSvc()->before("Callback",m_fcnMap[ff].name()); - if ((*ff)(i,resetKeys[ff]).isFailure()) { - auditorSvc()->after("Callback",m_fcnMap[ff].name()); - m_log << MSG::ERROR << "Problems calling " << m_fcnMap[ff].name() - << endreq; - return StatusCode::FAILURE; - } - auditorSvc()->after("Callback",m_fcnMap[ff].name()); + BFCN *ff = node->fcn(); + if (m_sortKeys) { resetKeys[ff].sort(); } + auditorSvc()->before("Callback",m_fcnMap[ff].name()); + if ((*ff)(i,resetKeys[ff]).isFailure()) { + auditorSvc()->after("Callback",m_fcnMap[ff].name()); + m_log << MSG::ERROR << "Problems calling " << m_fcnMap[ff].name() + << endreq; + return StatusCode::FAILURE; + } + auditorSvc()->after("Callback",m_fcnMap[ff].name()); } } } @@ -1117,7 +1253,7 @@ IOVSvcTool::triggerCallback(IOVSvcCallBackFcn* fcn, const std::string& key ) { StatusCode IOVSvcTool::triggerCallback( const SG::DataProxy *dp, - const std::string& key ) { + const std::string& key ) { #ifndef NDEBUG if (m_log.level() <= MSG::VERBOSE) { @@ -1129,7 +1265,7 @@ IOVSvcTool::triggerCallback( const SG::DataProxy *dp, m_proxyMap.find(dp); if (pitr == m_proxyMap.end()) { m_log << MSG::ERROR << "no callback associated with DataProxy " - << m_names[dp] << endreq; + << m_names[dp] << endreq; return StatusCode::FAILURE; } @@ -1147,22 +1283,22 @@ IOVSvcTool::PrintStartSet() { std::string objname; if (m_startSet_Clock.begin() != m_startSet_Clock.end()) { - m_log << endl << "ClockTime start set: " << endl; - for (start_itr = m_startSet_Clock.begin(); start_itr!=m_startSet_Clock.end(); ++start_itr ) { - objname = m_names[ (*start_itr)->proxy() ]; - m_log << " " << objname << " (" << (*start_itr)->proxy() << ") " - << (*start_itr)->range()->start() << endl; - } - m_log << endl; + m_log << endl << "ClockTime start set: " << endl; + for (start_itr = m_startSet_Clock.begin(); start_itr!=m_startSet_Clock.end(); ++start_itr ) { + objname = m_names[ (*start_itr)->proxy() ]; + m_log << " " << objname << " (" << (*start_itr)->proxy() << ") " + << (*start_itr)->range()->start() << endl; + } + m_log << endl; } if (m_startSet_RE.begin() != m_startSet_RE.end()) { - m_log << "Run/Event start set: " << endl; - for (start_itr = m_startSet_RE.begin(); start_itr!=m_startSet_RE.end();++start_itr ) { - objname = m_names[ (*start_itr)->proxy() ]; - m_log << " " << objname << " (" << (*start_itr)->proxy() << ") " - << (*start_itr)->range()->start() << endl; - } + m_log << "Run/Event start set: " << endl; + for (start_itr = m_startSet_RE.begin(); start_itr!=m_startSet_RE.end();++start_itr ) { + objname = m_names[ (*start_itr)->proxy() ]; + m_log << " " << objname << " (" << (*start_itr)->proxy() << ") " + << (*start_itr)->range()->start() << endl; + } } } @@ -1175,22 +1311,22 @@ IOVSvcTool::PrintStopSet() { std::string objname; if (m_stopSet_Clock.begin() != m_stopSet_Clock.end()) { - m_log << endl << "ClockTime stop set: " << endl; - for( stop_itr=m_stopSet_Clock.begin(); stop_itr!=m_stopSet_Clock.end(); ++stop_itr ) { - objname = m_names[ (*stop_itr)->proxy() ]; - m_log << " " << objname << " (" << (*stop_itr)->proxy() << ") " - << (*stop_itr)->range()->stop() << endl; - } - m_log << endl; + m_log << endl << "ClockTime stop set: " << endl; + for( stop_itr=m_stopSet_Clock.begin(); stop_itr!=m_stopSet_Clock.end(); ++stop_itr ) { + objname = m_names[ (*stop_itr)->proxy() ]; + m_log << " " << objname << " (" << (*stop_itr)->proxy() << ") " + << (*stop_itr)->range()->stop() << endl; + } + m_log << endl; } if (m_stopSet_RE.begin() != m_stopSet_RE.end()) { - m_log << "Run/Event stop set: " << endl; - for( stop_itr=m_stopSet_RE.begin(); stop_itr!=m_stopSet_RE.end(); ++stop_itr ) { - objname = m_names[ (*stop_itr)->proxy() ]; - m_log << " " << objname << " (" << (*stop_itr)->proxy() << ") " - << (*stop_itr)->range()->stop() << endl; - } + m_log << "Run/Event stop set: " << endl; + for( stop_itr=m_stopSet_RE.begin(); stop_itr!=m_stopSet_RE.end(); ++stop_itr ) { + objname = m_names[ (*stop_itr)->proxy() ]; + m_log << " " << objname << " (" << (*stop_itr)->proxy() << ") " + << (*stop_itr)->range()->stop() << endl; + } } } @@ -1200,7 +1336,7 @@ void IOVSvcTool::PrintProxyMap(){ m_log << endl; m_log << "------------------------------ IOVSvc Proxy Map " - << "------------------------------" << endl; + << "------------------------------" << endl; std::set<const DataProxy*>::const_iterator itr; for (itr=m_proxies.begin(); itr!=m_proxies.end(); ++itr) { @@ -1209,7 +1345,7 @@ IOVSvcTool::PrintProxyMap(){ } m_log << "----------------------------------------------------------" - << "---------------------" << endl; + << "---------------------" << endl; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -1218,7 +1354,7 @@ void IOVSvcTool::PrintProxyMap(const SG::DataProxy* dp){ m_log << " " << dp << " " << dp->transientAddress()->clID() << " " - << m_names.find(dp)->second << endl; + << m_names.find(dp)->second << endl; pair<pmITR,pmITR> pi = m_proxyMap.equal_range(dp); pmITR pitr; @@ -1240,9 +1376,9 @@ IOVSvcTool::PrintProxyMap(const SG::DataProxy* dp){ StatusCode IOVSvcTool::regFcn(SG::DataProxy* dp, - const CallBackID c, - const IOVSvcCallBackFcn& fcn, - bool trigger) { + const CallBackID c, + const IOVSvcCallBackFcn& fcn, + bool trigger) { std::string tname,fullname; StatusCode sc = p_CLIDSvc->getTypeNameOfID( dp->clID(), tname ); @@ -1255,9 +1391,9 @@ IOVSvcTool::regFcn(SG::DataProxy* dp, // see if proxy already bound if (m_proxies.find( dp ) == m_proxies.end()) { m_log << MSG::ERROR << "Cannot register object " << c.name() - << " with DataHandle " << fullname - << " -> Need to bind DataHandle first" - << endreq; + << " with DataHandle " << fullname + << " -> Need to bind DataHandle first" + << endreq; return StatusCode::FAILURE; } else { m_names[dp] = fullname; @@ -1266,13 +1402,13 @@ IOVSvcTool::regFcn(SG::DataProxy* dp, // if using old compiler, can't detect between non-virtual functions, // so issue an error. - #if (__GNUC__ < 3) +#if (__GNUC__ < 3) if (c.offset() == 0x7fff) { m_log << MSG::ERROR << "Callback function " << c.name() - << " is not virtual." << " Cannot bind it to " << fullname << endreq; + << " is not virtual." << " Cannot bind it to " << fullname << endreq; return StatusCode::FAILURE; } - #endif +#endif // check if this prox/function pair already registered @@ -1281,7 +1417,7 @@ IOVSvcTool::regFcn(SG::DataProxy* dp, for (pmITR p=fitr.first; p!=fitr.second; ++p) { if ( m_fcnMap[p->second] == c ) { m_log << MSG::ERROR << "CallBack function " << c.name() - << " already registered against " << fullname << endreq; + << " already registered against " << fullname << endreq; return StatusCode::FAILURE; } } @@ -1328,16 +1464,16 @@ IOVSvcTool::regFcn(SG::DataProxy* dp, #ifndef NDEBUG if (m_log.level() <= MSG::DEBUG) { m_log << MSG::DEBUG << "register by " << c.name() << " bound to " << fullname - << endreq; + << endreq; } #endif if (trigger) { if (m_first) { m_log << MSG::INFO - << "Still in initialize phase, not tiggering callback for " - << c.name() << " bound to " << fullname - << endreq; + << "Still in initialize phase, not tiggering callback for " + << c.name() << " bound to " << fullname + << endreq; } else { return triggerCallback(obs, dp->name()); } @@ -1350,8 +1486,8 @@ IOVSvcTool::regFcn(SG::DataProxy* dp, StatusCode IOVSvcTool::regFcn(const CallBackID c1, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger) { + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger) { // Check if second function has been registered with same proxy BFCN *obs1 = m_cbidMap[c1]; @@ -1366,19 +1502,19 @@ IOVSvcTool::regFcn(const CallBackID c1, std::pair<fnITR,fnITR> fi2 = m_bfcnMap.equal_range( obs2 ); for (fnITR fitr2=fi2.first; fitr2!=fi2.second; ++fitr2) { - const SG::DataProxy* prx2 = fitr2->second; + const SG::DataProxy* prx2 = fitr2->second; - if (prx1 == prx2) { + if (prx1 == prx2) { #ifndef NDEBUG - if (m_log.level() <= MSG::DEBUG) { - m_log << MSG::DEBUG << "Callback function " << c2.name() - << " cannot be registered since it has already been registered " - << "against " << m_names[prx1] << endreq; - } + if (m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "Callback function " << c2.name() + << " cannot be registered since it has already been registered " + << "against " << m_names[prx1] << endreq; + } #endif - } else { - proxyset.insert(prx1); // don't care if it gets done many times - } + } else { + proxyset.insert(prx1); // don't care if it gets done many times + } } } } else { @@ -1398,8 +1534,8 @@ IOVSvcTool::regFcn(const CallBackID c1, #ifndef NDEBUG if (m_log.level() <= MSG::DEBUG) { m_log << MSG::DEBUG << "Callback function " << c2.name() - << " cannot be registered, since it has already been registered" - << " against everything it can be." << endreq; + << " cannot be registered, since it has already been registered" + << " against everything it can be." << endreq; } #endif return StatusCode::SUCCESS; @@ -1422,11 +1558,11 @@ IOVSvcTool::regFcn(const CallBackID c1, const SG::DataProxy* prx = *pitr; m_proxyMap.insert(std::pair<const SG::DataProxy*,BFCN* >(prx,obs2)); m_bfcnMap.insert(std::pair<BFCN*,const SG::DataProxy*>(obs2,prx)); - + #ifndef NDEBUG if (m_log.level() <= MSG::DEBUG) { m_log << MSG::DEBUG << "register by " << c2.name() << " bound to " - << m_names[prx] << endreq; + << m_names[prx] << endreq; } #endif klist.push_back( prx->name() ); @@ -1442,7 +1578,7 @@ IOVSvcTool::regFcn(const CallBackID c1, CBNode *cp = m_trigTree->findNode(obs1); if (cp == 0) { m_log << MSG::ERROR << "regFcn: could not locate parent of " << cn->name() - << ". This should never happen" << endreq; + << ". This should never happen" << endreq; return StatusCode::FAILURE; } m_trigTree->connectNode(cn,cp); @@ -1452,9 +1588,9 @@ IOVSvcTool::regFcn(const CallBackID c1, if (trigger) { if (m_first) { m_log << MSG::INFO - << "Still in initialize phase, not tiggering callback for " - << c2.name() << " bound to " << *klist.begin() - << endreq; + << "Still in initialize phase, not tiggering callback for " + << c2.name() << " bound to " << *klist.begin() + << endreq; } else { return triggerCallback(obs2, *(klist.begin()) ); } @@ -1468,15 +1604,15 @@ IOVSvcTool::regFcn(const CallBackID c1, StatusCode IOVSvcTool::regFcn(const IAlgTool* ia, - const CallBackID c2, const IOVSvcCallBackFcn& fcn2, - bool trigger) { + const CallBackID c2, const IOVSvcCallBackFcn& fcn2, + bool trigger) { ObjMap::const_iterator oitr = m_objMap.find( ia ); if (oitr == m_objMap.end()) { - // tool not registered at all + // tool not registered at all m_log << MSG::ERROR << "No callback registered with AlgTool " << ia->name() - << endreq; + << endreq; return StatusCode::FAILURE; } else { @@ -1492,8 +1628,8 @@ IOVSvcTool::regFcn(const IAlgTool* ia, // there is more than one callback registered to this tool m_log << MSG::ERROR << "More than one callback registered to AlgTool " - << ia->name() << ". Found : " << sc->size() - << endreq; + << ia->name() << ". Found : " << sc->size() + << endreq; return StatusCode::FAILURE; } } @@ -1504,7 +1640,7 @@ IOVSvcTool::regFcn(const IAlgTool* ia, StatusCode IOVSvcTool::getTriggeredTools(const std::string& key, - std::set<std::string>& tools) { + std::set<std::string>& tools) { bool match = false; for (pmITR pitr=m_proxyMap.begin(); pitr != m_proxyMap.end(); ++pitr) { @@ -1522,16 +1658,16 @@ IOVSvcTool::getTriggeredTools(const std::string& key, StatusCode IOVSvcTool::reinitialize(){ - // Set flag to reset all proxies - m_resetAllCallbacks = true; - return (StatusCode::SUCCESS); + // Set flag to reset all proxies + m_resetAllCallbacks = true; + return (StatusCode::SUCCESS); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void IOVSvcTool::scanStartSet(startSet &pSet, const std::string &type, - std::set<const SG::DataProxy*, SortDPptr> &proxiesToReset) { + std::set<const SG::DataProxy*, SortDPptr> &proxiesToReset) { std::string objname; @@ -1546,8 +1682,8 @@ IOVSvcTool::scanStartSet(startSet &pSet, const std::string &type, if (m_resetAllCallbacks || (*start_itr)->range()->start() > m_curTime) { if (m_log.level() <= MSG::DEBUG) { - m_log << "\t" << m_names[ (*start_itr)->proxy() ] << ": " - << (*start_itr)->range()->start()<<" <- removed"<<endl; + m_log << "\t" << m_names[ (*start_itr)->proxy() ] << ": " + << (*start_itr)->range()->start()<<" <- removed"<<endl; } proxiesToReset.insert( (*start_itr)->proxy() ); @@ -1569,7 +1705,7 @@ IOVSvcTool::scanStartSet(startSet &pSet, const std::string &type, void IOVSvcTool::scanStopSet(stopSet &pSet, const std::string &type, - std::set<const SG::DataProxy*, SortDPptr> &proxiesToReset) { + std::set<const SG::DataProxy*, SortDPptr> &proxiesToReset) { std::string objname; @@ -1583,8 +1719,8 @@ IOVSvcTool::scanStopSet(stopSet &pSet, const std::string &type, if (m_resetAllCallbacks || (*stop_itr)->range()->stop() <= m_curTime) { if (m_log.level() <= MSG::DEBUG) { - m_log << " " << m_names[ (*stop_itr)->proxy() ] << ": " - << (*stop_itr)->range()->stop()<< " -> removed"<<endl; + m_log << " " << m_names[ (*stop_itr)->proxy() ] << ": " + << (*stop_itr)->range()->stop()<< " -> removed"<<endl; } proxiesToReset.insert( (*stop_itr)->proxy() ); @@ -1619,7 +1755,7 @@ IOVSvcTool::holdsProxy( const CLID& clid, const std::string& key ) const { if (proxy == 0) { m_log << MSG::ERROR << "holdsProxy: could not retrieve proxy " - << fullProxyName(clid,key) << " from store" << endreq; + << fullProxyName(clid,key) << " from store" << endreq; return false; } @@ -1658,7 +1794,7 @@ IOVSvcTool::resetAllProxies() { #ifndef NDEBUG if (m_log.level() <= MSG::VERBOSE) { m_log << MSG::VERBOSE << "clearing proxy payload for " << m_names[prx] - << endreq; + << endreq; } #endif diff --git a/Control/IOVSvc/src/components/IOVSvc_entries.cxx b/Control/IOVSvc/src/components/IOVSvc_entries.cxx index 3302abec7f275fb91d6ef5308dc8202e09d83cd1..50856f3eccd9f9dcfd96c238d70a8bd6b960231c 100755 --- a/Control/IOVSvc/src/components/IOVSvc_entries.cxx +++ b/Control/IOVSvc/src/components/IOVSvc_entries.cxx @@ -1,12 +1,18 @@ #include "IOVSvc/IOVSvc.h" +#include "IOVSvc/CondSvc.h" #include "IOVSvc/IOVSvcTool.h" +#include "../CondInputLoader.h" #include "GaudiKernel/DeclareFactoryEntries.h" DECLARE_SERVICE_FACTORY(IOVSvc) DECLARE_TOOL_FACTORY( IOVSvcTool ) -DECLARE_FACTORY_ENTRIES(IOVSvc) { - DECLARE_SERVICE( IOVSvc ); - DECLARE_TOOL( IOVSvcTool ); -} +DECLARE_SERVICE_FACTORY(CondSvc) + +DECLARE_ALGORITHM_FACTORY( CondInputLoader ) + +// DECLARE_FACTORY_ENTRIES(IOVSvc) { +// DECLARE_SERVICE( IOVSvc ); +// DECLARE_TOOL( IOVSvcTool ); +// } diff --git a/Control/IOVSvc/test/IOVSvc.xml b/Control/IOVSvc/test/IOVSvc.xml new file mode 100644 index 0000000000000000000000000000000000000000..d440b857b15f96ce5f42b9e1cddefccf58a2ec43 --- /dev/null +++ b/Control/IOVSvc/test/IOVSvc.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<atn> + <TEST name="IOVSvcTest" type="makecheck" suite="Core"> + <package>Control/IOVSvc</package> + <timelimit>10</timelimit> + <author> scott snyder </author> + <mailto> snyder@bnl.gov</mailto> + <expectations> + <errorMessage>Athena exited abnormally</errorMessage> + <errorMessage>differ</errorMessage> + <warningMessage> # WARNING_MESSAGE : post.sh> ERROR</warningMessage> + <successMessage>check ok</successMessage> + <returnValue>0</returnValue> + </expectations> + </TEST> +</atn> diff --git a/Control/IOVSvc/test/IOVSvcTool_test.cxx b/Control/IOVSvc/test/IOVSvcTool_test.cxx index 6132638a38e7e8a61d381a6ffcac3f4f8cc3de53..dcfb549beaa2d3e5443bd10b53f33018a4a6c225 100644 --- a/Control/IOVSvc/test/IOVSvcTool_test.cxx +++ b/Control/IOVSvc/test/IOVSvcTool_test.cxx @@ -2,6 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ +#undef NDEBUG #include "TestTools/initGaudi.h" #include "GaudiKernel/IToolSvc.h" #include "GaudiKernel/ISvcLocator.h" @@ -54,9 +55,9 @@ int main() { //initGaudi(pSvc); IToolSvc* pTS(0); assert((pSvc->service("ToolSvc", pTS, true)).isSuccess()); - IIOVSvcTool* pTool(0); - assert((pTS->retrieve("IOVSvcTool", IIOVSvcTool::interfaceID(), (IAlgTool*&)pTool, 0, true)).isSuccess()); - IOVSvcTool_test(pTool); + IAlgTool* pTool(0); + assert((pTS->retrieve("IOVSvcTool", IIOVSvcTool::interfaceID(), pTool, 0, true)).isSuccess()); + IOVSvcTool_test(dynamic_cast<IIOVSvcTool*>(pTool)); std::cout << "*** IOVSvcTool_test OK ***" << std::endl; return 0; }