@@ -98,10 +98,11 @@ void StfBuilderDevice::InitTask()
9898 I ().mMaxBuiltStfs = GetConfig ()->GetValue <std::uint64_t >(OptionKeyMaxBuiltStfs);
9999
100100 // partition id
101- I ().mPartitionId = Config::getPartitionOption (*GetConfig ()).value_or (DataDistLogger::sPartitionIdStr );
102- if (DataDistLogger::sPartitionIdStr .empty () && !I ().mPartitionId .empty ()) {
103- DataDistLogger::sPartitionIdStr = I ().mPartitionId ;
104- impl::DataDistLoggerCtx::InitInfoLogger ();
101+ I ().mPartitionId = Config::getPartitionOption (*GetConfig ()).value_or (" " );
102+ if (I ().mPartitionId .empty ()) {
103+ EDDLOG (" Partition id is not provided during InitTask(). Check command line or ECS parameters. Exiting." );
104+ ChangeState (fair::mq::Transition::ErrorFound);
105+ return ;
105106 }
106107
107108 // start monitoring
@@ -130,17 +131,18 @@ void StfBuilderDevice::InitTask()
130131 // check run type
131132 if (ReadoutDataUtils::sRunType == ReadoutDataUtils::RunType::eInvalid) {
132133 EDDLOG (" Run type paramter must be correctly set." );
133- throw std::logic_error (" Run type paramter must be correctly set." );
134+ ChangeState (fair::mq::Transition::ErrorFound);
135+ return ;
134136 }
135137
136138 // check run type
137139 if (ReadoutDataUtils::sRunType == ReadoutDataUtils::RunType::eTopology) {
138140 if (! ((ReadoutDataUtils::sSpecifiedDataOrigin == o2::header::gDataOriginITS ) ||
139141 (ReadoutDataUtils::sSpecifiedDataOrigin == o2::header::gDataOriginMFT ))) {
140-
141142 EDDLOG (" Run type paramter 'topology' is supported only for ITS and MFT. Please specify the detector option. detector={}" ,
142143 ReadoutDataUtils::sSpecifiedDataOrigin .as <std::string>());
143- throw std::logic_error (" Run type paramter 'topology' is supported only for ITS and MFT. Please specify the detector option." );
144+ ChangeState (fair::mq::Transition::ErrorFound);
145+ return ;
144146 }
145147 }
146148
@@ -166,12 +168,14 @@ void StfBuilderDevice::InitTask()
166168
167169 // File sink
168170 if (!I ().mFileSink ->loadVerifyConfig (*(this ->GetConfig ()))) {
169- std::this_thread::sleep_for (1s); exit (-1 );
171+ ChangeState (fair::mq::Transition::ErrorFound);
172+ return ;
170173 }
171174
172175 // File source
173176 if (!I ().mFileSource ->loadVerifyConfig (*(this ->GetConfig ()))) {
174- std::this_thread::sleep_for (1s); exit (-1 );
177+ ChangeState (fair::mq::Transition::ErrorFound);
178+ return ;
175179 }
176180
177181 // Discovery. Verify other parameters when running online and !standalone
@@ -185,17 +189,6 @@ void StfBuilderDevice::InitTask()
185189 lStatus.mutable_info ()->set_type (StfBuilder);
186190 lStatus.mutable_info ()->set_process_state (BasicInfo::NOT_RUNNING);
187191 lStatus.mutable_info ()->set_process_id (Config::getIdOption (StfBuilder, *GetConfig (), lConsulRequired));
188-
189- // wait for "partition-id"
190- while (!Config::getPartitionOption (*GetConfig ())) {
191- WDDLOG_RL (1000 , " StfBuilder waiting on 'discovery-partition' config parameter." );
192- std::this_thread::sleep_for (250ms);
193- }
194- if (I ().mPartitionId .empty ()) {
195- EDDLOG (" StfBuilder 'discovery-partition' parameter not set." );
196- std::this_thread::sleep_for (1s); exit (-1 );
197- }
198- I ().mPartitionId = Config::getPartitionOption (*GetConfig ()).value ();
199192 lStatus.mutable_partition ()->set_partition_id (I ().mPartitionId );
200193 I ().mDiscoveryConfig ->write ();
201194 }
@@ -209,14 +202,16 @@ void StfBuilderDevice::InitTask()
209202 (ReadoutDataUtils::sSpecifiedDataOrigin == o2::header::gDataOriginAny )) {
210203 EDDLOG (" Detector string parameter must be specified when receiving the data from the "
211204 " readout and not using RDHv6 or greater." );
212- std::this_thread::sleep_for (1s); exit (-1 );
205+ ChangeState (fair::mq::Transition::ErrorFound);
206+ return ;
213207 } else {
214208 IDDLOG (" READOUT INTERFACE: Configured detector: {}" , ReadoutDataUtils::sSpecifiedDataOrigin .as <std::string>());
215209 }
216210
217211 if (ReadoutDataUtils::sRdhVersion == ReadoutDataUtils::RdhVersion::eRdhInvalid) {
218212 EDDLOG (" The RDH version must be specified when receiving data from readout." );
219- std::this_thread::sleep_for (1s); exit (-1 );
213+ ChangeState (fair::mq::Transition::ErrorFound);
214+ return ;
220215 } else {
221216 IDDLOG (" READOUT INTERFACE: Configured RDHv{}" , ReadoutDataUtils::sRdhVersion );
222217 RDHReader::Initialize (unsigned (ReadoutDataUtils::sRdhVersion ));
@@ -254,7 +249,8 @@ void StfBuilderDevice::InitTask()
254249 GetChannel (I ().mInputChannelName );
255250 } catch (std::exception &) {
256251 EDDLOG (" Input channel not configured (from o2-readout-exe) and not running with file source enabled." );
257- std::this_thread::sleep_for (1s); exit (-1 );
252+ ChangeState (fair::mq::Transition::ErrorFound);
253+ return ;
258254 }
259255 }
260256
@@ -264,7 +260,8 @@ void StfBuilderDevice::InitTask()
264260 }
265261 } catch (std::exception &e) {
266262 EDDLOG (" Output channel (to DPL or StfSender) must be configured if not running in stand-alone mode." );
267- std::this_thread::sleep_for (1s); exit (-1 );
263+ ChangeState (fair::mq::Transition::ErrorFound);
264+ return ;
268265 }
269266 }
270267
@@ -337,6 +334,8 @@ void StfBuilderDevice::StfOutputThread()
337334
338335 decltype (hres_clock::now ()) lStfStartTime = hres_clock::now ();
339336
337+ DDMON_RATE (" stfbuilder" , " stf_output" , 0.0 );
338+
340339 while (I ().mState .mRunning ) {
341340 // Get a STF ready for sending, or nullopt
342341 auto lStfOpt = I ().dequeue_for (eStfSendIn, 100ms);
@@ -358,13 +357,12 @@ void StfBuilderDevice::StfOutputThread()
358357
359358 lShouldSendEos = true ;
360359 if (lStfOpt == std::nullopt ) {
361- DDMON (" stfbuilder" , " stf_output.rate" , 0 );
362- DDMON (" stfbuilder" , " stf_output.size" , 0 );
363360 DDMON (" stfbuilder" , " data_output.rate" , 0 );
364361 continue ;
365362 }
366363
367364 auto &lStf = lStfOpt.value ();
365+ DDMON_RATE (" stfbuilder" , " stf_output" , lStf->getDataSize ());
368366
369367 // decrement the stf counter
370368 I ().mCounters .mNumStfs --;
@@ -379,8 +377,6 @@ void StfBuilderDevice::StfOutputThread()
379377 lStfStartTime = lNow;
380378
381379 const auto lRate = 1.0 / std::max (lStfDur.count (), 0.00001 );
382- DDMON (" stfbuilder" , " stf_output.rate" , lRate);
383- DDMON (" stfbuilder" , " stf_output.size" , lStf->getDataSize ());
384380 DDMON (" stfbuilder" , " stf_output.id" , lStf->id ());
385381 DDMON (" stfbuilder" , " data_output.rate" , (lRate * lStf->getDataSize ()));
386382 }
0 commit comments