Skip to content

Commit d2a7cd6

Browse files
committed
o2-sim: Improve communication between primary server and transport workers
More robust communication between primary servery and sim workers: a) answer req-rep primary channel immediately (even if no work) - avoid blocking in request handling - also don't need to specify timeouts anymore b) include server status information as header - this may be used by workers to back-off/retry This solves some stability issues with the sim-as-a-service. The 2 examples SimAsService_basic / SimAsService_biasing1 now run stably.
1 parent d20cc82 commit d2a7cd6

9 files changed

Lines changed: 375 additions & 199 deletions

File tree

run/O2HitMerger.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class O2HitMerger : public FairMQDevice
125125

126126
std::string outfilename("o2sim_merged_hits.root"); // default name
127127
// query the sim config ... which is used to extract the filenames
128-
if (o2::devices::O2SimDevice::querySimConfig(fChannels.at("primary-get").at(0))) {
128+
if (o2::devices::O2SimDevice::querySimConfig(fChannels.at("o2sim-primserv-info").at(0))) {
129129
outfilename = o2::base::NameConf::getMCKinematicsFileName(o2::conf::SimConfig::Instance().getOutPrefix().c_str());
130130
mNExpectedEvents = o2::conf::SimConfig::Instance().getNEvents();
131131
}
@@ -175,18 +175,24 @@ class O2HitMerger : public FairMQDevice
175175
// a) dir is relative dir. Then we interpret it as relative to the initial
176176
// base directory
177177
// b) or dir is itself absolut.
178-
fs::current_path(fs::path(mInitialOutputDir)); // <--- to make sure relative start is always the same
179-
auto absolutePath = fs::absolute(fs::path(dir));
180-
if (!fs::exists(absolutePath)) {
181-
if (!fs::create_directory(absolutePath)) {
182-
LOG(ERROR) << "Could not create directory " << absolutePath.string();
183-
return false;
178+
try {
179+
fs::current_path(fs::path(mInitialOutputDir)); // <--- to make sure relative start is always the same
180+
if (!dir.empty()) {
181+
auto absolutePath = fs::absolute(fs::path(dir));
182+
if (!fs::exists(absolutePath)) {
183+
if (!fs::create_directory(absolutePath)) {
184+
LOG(ERROR) << "Could not create directory " << absolutePath.string();
185+
return false;
186+
}
187+
}
188+
// set the current path
189+
fs::current_path(absolutePath.string().c_str());
190+
mCurrentOutputDir = fs::current_path().string();
184191
}
192+
LOG(INFO) << "FINAL PATH " << mCurrentOutputDir;
193+
} catch (std::exception e) {
194+
LOG(ERROR) << " could not change path to " << dir;
185195
}
186-
// set the current path
187-
fs::current_path(absolutePath.string().c_str());
188-
mCurrentOutputDir = fs::current_path().string();
189-
LOG(INFO) << "FINAL PATH " << mCurrentOutputDir;
190196
return true;
191197
}
192198

0 commit comments

Comments
 (0)