Skip to content

Commit d470471

Browse files
committed
[occ] Clarified upstream, channel creation workaround still needed
This reverts commit 283deff.
1 parent 78ac922 commit d470471

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

occ/plugin/OccPluginServer.cxx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,49 @@ OccPluginServer::Transition(grpc::ServerContext* context,
307307

308308
try {
309309
auto evt = fair::mq::PluginServices::ToDeviceStateTransition(event);
310+
311+
// FIXME: big ugly workaround over here
312+
// Since FairMQ currently (11/2018) can't yet implicitly create channels when receiving
313+
// chans.* properties during INITIALIZING DEVICE, we must fake a --channel-config cli
314+
// parameter during INIT and before the INIT DEVICE event.
315+
// We extract channel related properties from the OCC transition arguments vector and we
316+
// build up a vector of strings which mimics stuff along the lines of
317+
// --channel-config name=data,type=push,method=bind,address=tcp://*:5555,rateLogging=0"
318+
// See https://github.com/FairRootGroup/FairMQ/pull/111
319+
// When the relevant FairMQ 1.4.x version implements implicit channel creation, this whole
320+
// block should be removed with no loss of functionality.
321+
if (evt == fair::mq::PluginServices::DeviceStateTransition::InitDevice) {
322+
std::unordered_map<std::string, std::unordered_map<std::string, std::string>> channels;
323+
for (auto it = arguments.cbegin(); it != arguments.cend(); ++it) {
324+
auto key = it->key();
325+
if (boost::starts_with(key, "chans.")) {
326+
key.erase(0, 6);
327+
std::vector<std::string> split;
328+
boost::split(split, key, std::bind1st(std::equal_to<char>(), '.'));
329+
if (split.size() != 3)
330+
continue;
331+
auto name = split[0];
332+
auto propKey = split[2];
333+
if (channels.find(name) == channels.end()) // if map for this chan doesn't exist yet
334+
channels[name] = std::unordered_map<std::string, std::string>();
335+
channels[name][propKey] = it->value();
336+
}
337+
}
338+
339+
std::vector<std::string> channelLines;
340+
for (auto it = channels.cbegin(); it != channels.cend(); ++it) {
341+
std::vector<std::string> line;
342+
line.push_back("name=" + it->first);
343+
for (auto jt = it->second.cbegin(); jt != it->second.cend(); ++jt) {
344+
line.push_back(jt->first + "=" + jt->second);
345+
}
346+
channelLines.push_back(boost::join(line, ","));
347+
OLOG(DEBUG) << "[request Transition] pushing channel configuration " << channelLines.back();
348+
}
349+
if (!channelLines.empty()) {
350+
m_pluginServices->SetProperty("channel-config", channelLines);
351+
}
352+
}
310353
m_pluginServices->ChangeDeviceState("OCC", evt);
311354
}
312355
catch (fair::mq::PluginServices::DeviceControlError& e) {

0 commit comments

Comments
 (0)