@@ -69,9 +69,56 @@ std::size_t CheckRunner::hash(const std::string& inputString)
6969 return checksum;
7070}
7171
72- std::string CheckRunner::createCheckRunnerName ()
72+ std::string CheckRunner::createCheckRunnerName (const std::vector<CheckConfig>& checks )
7373{
74- return CheckRunner::createCheckRunnerIdString ();
74+ static const std::string alphanumeric =
75+ " 0123456789"
76+ " ABCDEFGHIJKLMNOPQRSTUVWXYZ"
77+ " abcdefghijklmnopqrstuvwxyz" ;
78+ const int NAME_LEN = 4 ;
79+ std::string name (CheckRunner::createCheckRunnerIdString () + " -" + getDetectorName (checks) + " -" );
80+
81+ if (checks.size () == 1 ) {
82+ // If single check, use the check name
83+ name += checks[0 ].name ;
84+ } else {
85+ std::string hash_string;
86+ std::vector<std::string> names;
87+ // Fill vector with check names
88+ for (const auto & c : checks) {
89+ names.push_back (c.name );
90+ }
91+ // Be sure that after configuration shuffle, the name will be the same
92+ std::sort (names.begin (), names.end ());
93+
94+ // Create a single string and hash it
95+ for (auto & n : names) {
96+ hash_string += n;
97+ }
98+ std::size_t num = hash (hash_string);
99+
100+ // Change numerical to alphanumeric hash representation
101+ for (int i = 0 ; i < NAME_LEN ; ++i) {
102+ name += alphanumeric[num % alphanumeric.size ()];
103+ num = num / alphanumeric.size ();
104+ }
105+ }
106+ return name;
107+ }
108+
109+ std::string CheckRunner::createCheckRunnerFacility (std::string deviceName)
110+ {
111+ // it starts with "check/" and is followed by the unique part of the device name truncated to a maximum of 32 characters.
112+ string facilityName = " check/" + deviceName.substr (CheckRunner::createCheckRunnerIdString ().length () + 1 , string::npos);
113+ facilityName = facilityName.substr (0 , 32 );
114+ return facilityName;
115+ }
116+
117+ std::string CheckRunner::createSinkCheckRunnerName (InputSpec input)
118+ {
119+ std::string name (CheckRunner::createCheckRunnerIdString () + " -sink-" );
120+ name += DataSpecUtils::label (input);
121+ return name;
75122}
76123
77124o2::framework::Outputs CheckRunner::collectOutputs (const std::vector<CheckConfig>& checkConfigs)
@@ -83,12 +130,13 @@ o2::framework::Outputs CheckRunner::collectOutputs(const std::vector<CheckConfig
83130 return outputs;
84131}
85132
86- CheckRunner::CheckRunner (CheckRunnerConfig checkRunnerConfig, const std::vector<CheckConfig>& checkConfigs, o2::framework::Inputs inputs )
133+ CheckRunner::CheckRunner (CheckRunnerConfig checkRunnerConfig, const std::vector<CheckConfig>& checkConfigs)
87134 : mDetectorName (getDetectorName(checkConfigs)),
88- mDeviceName (createCheckRunnerName()),
135+ mDeviceName (createCheckRunnerName(checkConfigs )),
89136 mConfig(std::move(checkRunnerConfig)),
90- mInputs{ inputs },
91- mOutputs { CheckRunner::collectOutputs (checkConfigs) },
137+ /* All checks have the same Input */
138+ mInputs(checkConfigs.front().inputSpecs),
139+ mOutputs(CheckRunner::collectOutputs(checkConfigs)),
92140 mTotalNumberObjectsReceived(0 ),
93141 mTotalNumberCheckExecuted(0 ),
94142 mTotalNumberQOStored(0 ),
@@ -100,6 +148,19 @@ CheckRunner::CheckRunner(CheckRunnerConfig checkRunnerConfig, const std::vector<
100148 }
101149}
102150
151+ CheckRunner::CheckRunner (CheckRunnerConfig checkRunnerConfig, InputSpec input)
152+ : mDeviceName(createSinkCheckRunnerName(input)),
153+ mConfig(std::move(checkRunnerConfig)),
154+ mInputs{ input },
155+ mOutputs {},
156+ mTotalNumberObjectsReceived (0 ),
157+ mTotalNumberCheckExecuted (0 ),
158+ mTotalNumberQOStored (0 ),
159+ mTotalNumberMOStored (0 ),
160+ mTotalQOSent (0 )
161+ {
162+ }
163+
103164CheckRunner::~CheckRunner ()
104165{
105166 ILOG (Debug, Trace) << " CheckRunner destructor (" << this << " )" << ENDM ;
@@ -151,7 +212,7 @@ void CheckRunner::refreshConfig(InitContext& iCtx)
151212void CheckRunner::init (framework::InitContext& iCtx)
152213{
153214 try {
154- core::initInfologger (iCtx, mConfig .infologgerDiscardParameters , mDeviceName );
215+ core::initInfologger (iCtx, mConfig .infologgerDiscardParameters , createCheckRunnerFacility ( mDeviceName ) );
155216 refreshConfig (iCtx);
156217 Bookkeeping::getInstance ().init (mConfig .bookkeepingUrl );
157218 initDatabase ();
@@ -197,7 +258,7 @@ void CheckRunner::run(framework::ProcessingContext& ctx)
197258
198259 auto now = getCurrentTimestamp ();
199260 store (qualityObjects, now);
200- store (mToBeStored , now);
261+ store (mMonitorObjectStoreVector , now);
201262
202263 send (qualityObjects, ctx.outputs ());
203264
@@ -209,7 +270,7 @@ void CheckRunner::run(framework::ProcessingContext& ctx)
209270
210271void CheckRunner::prepareCacheData (framework::InputRecord& inputRecord)
211272{
212- mToBeStored .clear ();
273+ mMonitorObjectStoreVector .clear ();
213274
214275 for (const auto & input : mInputs ) {
215276 auto dataRef = inputRecord.get (input.binding .c_str ());
@@ -239,6 +300,7 @@ void CheckRunner::prepareCacheData(framework::InputRecord& inputRecord)
239300
240301 // for each item of the array, check whether it is a MonitorObject. If not, create one and encapsulate.
241302 // Then, store the MonitorObject in the various maps and vectors we will use later.
303+ bool store = mInputStoreSet .count (DataSpecUtils::label (input)) > 0 ; // Check if this CheckRunner stores this input
242304 for (const auto tObject : *array) {
243305 std::shared_ptr<MonitorObject> mo{ dynamic_cast <MonitorObject*>(tObject) };
244306
@@ -256,8 +318,9 @@ void CheckRunner::prepareCacheData(framework::InputRecord& inputRecord)
256318 updatePolicyManager.updateObjectRevision (mo->getFullName ());
257319 mTotalNumberObjectsReceived ++;
258320
259- // Monitor Object will be stored later, after possible beautification
260- mToBeStored .push_back (mo);
321+ if (store) { // Monitor Object will be stored later, after possible beautification
322+ mMonitorObjectStoreVector .push_back (mo);
323+ }
261324 }
262325 }
263326 }
@@ -288,7 +351,7 @@ void CheckRunner::sendPeriodicMonitoring()
288351
289352QualityObjectsType CheckRunner::check ()
290353{
291- ILOG (Debug, Devel) << " check(): Trying " << mChecks .size () << " checks for " << mMonitorObjects .size () << " monitor objects"
354+ ILOG (Debug, Devel) << " Trying " << mChecks .size () << " checks for " << mMonitorObjects .size () << " monitor objects"
292355 << ENDM ;
293356
294357 QualityObjectsType allQOs;
@@ -491,7 +554,7 @@ void CheckRunner::reset()
491554 mTotalQOSent = 0 ;
492555}
493556
494- std::string CheckRunner::getDetectorName (const std::vector<CheckConfig>& checks)
557+ std::string CheckRunner::getDetectorName (const std::vector<CheckConfig> checks)
495558{
496559 std::string detectorName;
497560 for (auto & check : checks) {
0 commit comments