Support node specific remaps in LogReader
When we have a bunch of nodes running similar pieces of software, we end
up with a bunch of channels which are all the same, bar a prefix. The
applications then end up with node specific maps to avoid being
different everywhere.
When renaming those in replay, we need to recreate both the node
specific map, and take the map into account when renaming. We don't
want to leak the naming pattern up.
Change-Id: I6a6a0556bf49664679f443a21eaed23d024a515f
diff --git a/aos/events/logging/logger.h b/aos/events/logging/logger.h
index a3189db..ba76424 100644
--- a/aos/events/logging/logger.h
+++ b/aos/events/logging/logger.h
@@ -258,11 +258,28 @@
RemapLoggedChannel(name, T::GetFullyQualifiedName(), add_prefix);
}
+ // Remaps the provided channel, though this respects node mappings, and
+ // preserves them too. This makes it so if /aos -> /pi1/aos on one node,
+ // /original/aos -> /original/pi1/aos on the same node after renaming, just
+ // like you would hope.
+ //
+ // TODO(austin): If you have 2 nodes remapping something to the same channel,
+ // this doesn't handle that. No use cases exist yet for that, so it isn't
+ // being done yet.
+ void RemapLoggedChannel(std::string_view name, std::string_view type,
+ const Node *node,
+ std::string_view add_prefix = "/original");
template <typename T>
- bool HasChannel(std::string_view name) {
+ void RemapLoggedChannel(std::string_view name, const Node *node,
+ std::string_view add_prefix = "/original") {
+ RemapLoggedChannel(name, T::GetFullyQualifiedName(), node, add_prefix);
+ }
+
+ template <typename T>
+ bool HasChannel(std::string_view name, const Node *node = nullptr) {
return configuration::GetChannel(log_file_header()->configuration(), name,
T::GetFullyQualifiedName(), "",
- nullptr) != nullptr;
+ node) != nullptr;
}
SimulatedEventLoopFactory *event_loop_factory() {
@@ -583,6 +600,7 @@
// logged_configuration(), and the string key will be the name of the channel
// to send on instead of the logged channel name.
std::map<size_t, std::string> remapped_channels_;
+ std::vector<MapT> maps_;
// Number of nodes which still have data to send. This is used to figure out
// when to exit.