From: richterm Date: Wed, 23 Jan 2008 19:30:45 +0000 (+0000) Subject: initialization of CDB in wrapper interface;added treatment of reconfiguration event X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=579d9eb79be7cb4575ff09392324e47da4a81e12 initialization of CDB in wrapper interface;added treatment of reconfiguration event --- diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx index 0e999b9c73d..db222bdbeec 100644 --- a/HLT/BASE/AliHLTComponent.cxx +++ b/HLT/BASE/AliHLTComponent.cxx @@ -43,6 +43,7 @@ using namespace std; #include "TClass.h" #include "TStopwatch.h" #include "AliHLTMemoryFile.h" +#include "AliHLTMisc.h" #include /** ROOT macro for the implementation of ROOT specific class methods */ @@ -76,8 +77,9 @@ AliHLTComponent::AliHLTComponent() fpStopwatches(new TObjArray(kSWTypeCount)), fMemFiles(), fpRunDesc(NULL), - fpDDLList(NULL) - + fpDDLList(NULL), + fCDBInitialized(false), + fChainId() { // see header file for class documentation // or @@ -197,23 +199,61 @@ int AliHLTComponent::Deinit() fpRunDesc=NULL; delete pRunDesc; } + fEventCount=0; return iResult; } -int AliHLTComponent::DoInit( int argc, const char** argv ) +int AliHLTComponent::InitCDB(const char* cdbPath) { - // see header file for function documentation - if (argc==0 && argv==NULL) { - // this is currently just to get rid of the warning "unused parameter" + int iResult=0; + // we presume the library already to be loaded + // find the symbol + AliHLTComponentHandler cHandler; + AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)cHandler.FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB); + if (pFunc) { + iResult=(*pFunc)(cdbPath); + fCDBInitialized=iResult>=0; + } else { + Message(NULL, kHLTLogError, "AliHLTComponent::InitCDB", "init CDB", + "can not find initialization function"); + iResult=-ENOSYS; } - fEventCount=0; + return iResult; +} + +int AliHLTComponent::SetCDBRunNo(int runNo) +{ + int iResult=0; + if (!fCDBInitialized) return iResult; + // we presume the library already to be loaded + // find the symbol + AliHLTComponentHandler cHandler; + AliHLTMiscSetCDBRunNo_t pFunc=(AliHLTMiscSetCDBRunNo_t)cHandler.FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_SET_CDB_RUNNO); + if (pFunc) { + iResult=(*pFunc)(runNo); + } else { + Message(NULL, kHLTLogError, "AliHLTComponent::SetCDBRunNo", "init CDB", + "can not find initialization function"); + iResult=-ENOSYS; + } + return iResult; +} + +int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/) +{ + // default implementation, childs can overload return 0; } int AliHLTComponent::DoDeinit() { - // see header file for function documentation - fEventCount=0; + // default implementation, childs can overload + return 0; +} + +int AliHLTComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) +{ + // default implementation, childs can overload return 0; } @@ -1078,42 +1118,67 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, // find special events if (fpInputBlocks) { + // first look for all special events and execute in the appropriate + // sequence afterwords + int indexComConfEvent=-1; + int indexSOREvent=-1; + int indexEOREvent=-1; for (unsigned int i=0; i=0; i++) { if (fpInputBlocks[i].fDataType==kAliHLTDataTypeSOR) { - // start of run - if (fpRunDesc==NULL) { - fpRunDesc=new AliHLTRunDesc; - if (fpRunDesc) { - if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) { - HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo); - } - } else { - iResult=-ENOMEM; + indexSOREvent=i; + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) { + indexEOREvent=i; + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) { + // DDL list + // this event is most likely deprecated + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComConf) { + indexComConfEvent=i; + } + } + if (indexSOREvent>=0) { + // start of run + if (fpRunDesc==NULL) { + fpRunDesc=new AliHLTRunDesc; + if (fpRunDesc) { + if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), indexSOREvent, "AliHLTRunDesc", "SOR"))>0) { + HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo); + SetCDBRunNo(fpRunDesc->fRunNo); } } else { - HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo); + iResult=-ENOMEM; } - } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) { - if (fpRunDesc!=NULL) { - if (fpRunDesc) { - AliHLTRunDesc rundesc; - if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) { - if (fpRunDesc->fRunNo!=rundesc.fRunNo) { - HLTWarning("run no missmatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo); - } else { - HLTDebug("EOR run no %d", fpRunDesc->fRunNo); - } + } else { + HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo); + } + } + if (indexEOREvent>=0) { + if (fpRunDesc!=NULL) { + if (fpRunDesc) { + AliHLTRunDesc rundesc; + if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexEOREvent, "AliHLTRunDesc", "SOR"))>0) { + if (fpRunDesc->fRunNo!=rundesc.fRunNo) { + HLTWarning("run no missmatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo); + } else { + HLTDebug("EOR run no %d", fpRunDesc->fRunNo); } - AliHLTRunDesc* pRunDesc=fpRunDesc; - fpRunDesc=NULL; - delete pRunDesc; } - } else { - HLTWarning("did not receive SOR, ignoring EOR"); + AliHLTRunDesc* pRunDesc=fpRunDesc; + fpRunDesc=NULL; + delete pRunDesc; } - // end of run - } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) { - // DDL list + } else { + HLTWarning("did not receive SOR, ignoring EOR"); + } + } + if (indexComConfEvent>=0) { + TString cdbEntry; + if (fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) { + cdbEntry.Append(reinterpret_cast(fpInputBlocks[indexComConfEvent].fPtr), fpInputBlocks[indexComConfEvent].fSize); + } + HLTDebug("received component configuration command: entry %s", cdbEntry.IsNull()?"none":cdbEntry.Data()); + int tmpResult=Reconfigure(cdbEntry[0]==0?NULL:cdbEntry.Data(), fChainId.c_str()); + if (tmpResult<0) { + HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult); } } } diff --git a/HLT/BASE/AliHLTComponent.h b/HLT/BASE/AliHLTComponent.h index 91e00268f96..f4586e6a297 100644 --- a/HLT/BASE/AliHLTComponent.h +++ b/HLT/BASE/AliHLTComponent.h @@ -323,6 +323,28 @@ class AliHLTComponent : public AliHLTLogging { AliHLTComponentBlockDataList& outputBlocks, AliHLTComponentEventDoneData*& edd ) = 0; + /** + * Init the CDB. + * The function must not be called when running in AliRoot unless it it + * really wanted. The CDB path will be set to the specified path, which might + * override the path initialized at the beginning of the AliRoot reconstruction. + * + * The method is used from the external interface in order to set the correct + * path when running on-line. + */ + int InitCDB(const char* cdbPath); + + /** + * Set the run no for the CDB. + * The function must not be called when running in AliRoot unless it it + * really wanted. The CDB path will be set to the specified path, which might + * override the run no initialized at the beginning of the AliRoot reconstruction. + * + * The method is used from the external interface in order to set the correct + * path when running on-line. + */ + int SetCDBRunNo(int runNo); + // Information member functions for registration. /** @@ -572,6 +594,25 @@ class AliHLTComponent : public AliHLTLogging { */ virtual int DoDeinit(); + /** + * Reconfigure the component. + * The method is called when an event of type @ref kAliHLTDataTypeComConf + * {COM_CONF:PRIV} is received by the component. If the event is sent as + * part of a normal event, the component configuration is called first. + * + * The CDB path parameter specifies the path in the CDB, i.e. without + * leading absolute path of the CDB location. The framework might alse + * provide the id of the component in the analysis chain. + * + * \b Note: The CDB will be initialized by the framework, either already set + * from AliRoot or from the wrapper interface during initialization. + * + * @param cdbEntry path of the cdbEntry + * @param chainId the id of the component in the analysis chain + * @note both parameters can be NULL, check before usage + */ + virtual int Reconfigure(const char* cdbEntry, const char* chainId); + /** * General memory allocation method. * All memory which is going to be used 'outside' of the interface must @@ -1149,6 +1190,12 @@ class AliHLTComponent : public AliHLTLogging { /** the current DDL list */ AliHLTEventDDL* fpDDLList; //! transient - ClassDef(AliHLTComponent, 3) + /** indicates that the CDB has been initialized locally */ + bool fCDBInitialized; //! transient + + /** id of the component in the analysis chain */ + string fChainId; //! transient + + ClassDef(AliHLTComponent, 4) }; #endif diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx index f53f65a4e24..e4329d96659 100644 --- a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx @@ -90,6 +90,11 @@ int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, in if ( !handle ) return EINVAL; AliHLTComponent* comp; int ret = gComponentHandler_C->CreateComponent( componentType, environ_param, argc, argv, comp ); + if (comp) { + const char* cdbPath = getenv("ALIHLT_HCDBDIR"); + if (!cdbPath) cdbPath = getenv("ALICE_ROOT"); + if (cdbPath) comp->InitCDB(cdbPath); + } *handle = reinterpret_cast( comp ); return ret; diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.h b/HLT/BASE/AliHLT_C_Component_WrapperInterface.h index 4b25b8737ca..14448c69ea2 100644 --- a/HLT/BASE/AliHLT_C_Component_WrapperInterface.h +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.h @@ -20,6 +20,9 @@ * * \image html PubSub_WrapperComponent.png "Wrapper interface" * + * CDB handling: The interface initializes the CDB from the path found + * in the environment variable ALIHLT_HCDBDIR. Default path is + * $ALICE_ROOT. */ #include diff --git a/HLT/BASE/util/AliHLTFileWriter.h b/HLT/BASE/util/AliHLTFileWriter.h index ff6d9f01ed3..8ab5de342f9 100644 --- a/HLT/BASE/util/AliHLTFileWriter.h +++ b/HLT/BASE/util/AliHLTFileWriter.h @@ -21,7 +21,7 @@ * An HLT data sink component which writes data to file(s). * * Component ID: \b FileWriter
- * Library: \b libAliHLTUtil. + * Library: \b libAliHLTUtil.so * * Mandatory arguments:
* diff --git a/HLT/libHLTrec.pkg b/HLT/libHLTrec.pkg index 7f0f6675921..c4803b07e5c 100644 --- a/HLT/libHLTrec.pkg +++ b/HLT/libHLTrec.pkg @@ -9,6 +9,7 @@ CLASS_HDRS:= AliHLTReconstructor.h \ AliHLTOUTRawReader.h MODULE_SRCS:= AliHLTDynamicAliLog.cxx \ + AliHLTMisc.cxx \ $(CLASS_HDRS:.h=.cxx) MODULE_HDRS:= $(CLASS_HDRS) diff --git a/HLT/rec/AliHLTMisc.cxx b/HLT/rec/AliHLTMisc.cxx new file mode 100644 index 00000000000..c9927032244 --- /dev/null +++ b/HLT/rec/AliHLTMisc.cxx @@ -0,0 +1,55 @@ +// @(#) $Id: AliHLTDynamicAliLog.cxx 23318 2008-01-14 12:43:28Z hristov $ + +/************************************************************************** + * This file is property of and copyright by the ALICE HLT Project * + * ALICE Experiment at CERN, All rights reserved. * + * * + * Primary Authors: Matthias Richter * + * for The ALICE HLT Project. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/** @file AliHLTMisc.cxx + @author Matthias Richter + @date + @brief Miscellaneous methods for the HLT AliRoot integration +*/ + +#include "AliHLTMisc.h" +#include "AliHLTLogging.h" +#include "AliCDBManager.h" + +int AliHLTMiscInitCDB(const char* cdbpath) +{ + int iResult=0; + AliCDBManager* pCDB = AliCDBManager::Instance(); + AliHLTLogging log; + if (!pCDB) { + log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); + } else { + pCDB->SetRun(0); // This will be retrieved during the SOR event + pCDB->SetDefaultStorage(cdbpath); + log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB); + } + return iResult; +} + +int AliHLTMiscSetCDBRunNo(int runNo) +{ + int iResult=0; + AliCDBManager* pCDB = AliCDBManager::Instance(); + AliHLTLogging log; + if (!pCDB) { + log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); + } else { + pCDB->SetRun(runNo); + } + return iResult; +}