Austin Schuh | b06f03b | 2021-02-17 22:00:37 -0800 | [diff] [blame] | 1 | #ifndef AOS_EVENTS_LOGGING_LOG_READER_H_ |
| 2 | #define AOS_EVENTS_LOGGING_LOG_READER_H_ |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 3 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 4 | #include <chrono> |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 5 | #include <deque> |
Austin Schuh | 05b7047 | 2020-01-01 17:11:17 -0800 | [diff] [blame] | 6 | #include <string_view> |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 7 | #include <tuple> |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 8 | #include <vector> |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 9 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 10 | #include "aos/events/event_loop.h" |
Austin Schuh | f6f9bf3 | 2020-10-11 14:37:43 -0700 | [diff] [blame] | 11 | #include "aos/events/logging/logfile_sorting.h" |
Austin Schuh | a36c890 | 2019-12-30 18:07:15 -0800 | [diff] [blame] | 12 | #include "aos/events/logging/logfile_utils.h" |
James Kuszmaul | 38735e8 | 2019-12-07 16:42:06 -0800 | [diff] [blame] | 13 | #include "aos/events/logging/logger_generated.h" |
Austin Schuh | 9254752 | 2019-12-28 14:33:43 -0800 | [diff] [blame] | 14 | #include "aos/events/simulated_event_loop.h" |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 15 | #include "aos/network/message_bridge_server_generated.h" |
Austin Schuh | 0ca1fd3 | 2020-12-18 22:53:05 -0800 | [diff] [blame] | 16 | #include "aos/network/multinode_timestamp_filter.h" |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 17 | #include "aos/network/remote_message_generated.h" |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 18 | #include "aos/network/timestamp_filter.h" |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 19 | #include "aos/time/time.h" |
Austin Schuh | 4385b14 | 2021-03-14 21:31:13 -0700 | [diff] [blame] | 20 | #include "aos/uuid.h" |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 21 | #include "flatbuffers/flatbuffers.h" |
| 22 | |
| 23 | namespace aos { |
| 24 | namespace logger { |
| 25 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 26 | // We end up with one of the following 3 log file types. |
| 27 | // |
| 28 | // Single node logged as the source node. |
| 29 | // -> Replayed just on the source node. |
| 30 | // |
| 31 | // Forwarding timestamps only logged from the perspective of the destination |
| 32 | // node. |
| 33 | // -> Matched with data on source node and logged. |
| 34 | // |
| 35 | // Forwarding timestamps with data logged as the destination node. |
| 36 | // -> Replayed just as the destination |
| 37 | // -> Replayed as the source (Much harder, ordering is not defined) |
| 38 | // |
| 39 | // Duplicate data logged. -> CHECK that it matches and explode otherwise. |
| 40 | // |
| 41 | // This can be boiled down to a set of constraints and tools. |
| 42 | // |
| 43 | // 1) Forwarding timestamps and data need to be logged separately. |
| 44 | // 2) Any forwarded data logged on the destination node needs to be logged |
| 45 | // separately such that it can be sorted. |
| 46 | // |
| 47 | // 1) Log reader needs to be able to sort a list of log files. |
| 48 | // 2) Log reader needs to be able to merge sorted lists of log files. |
| 49 | // 3) Log reader needs to be able to match timestamps with messages. |
| 50 | // |
| 51 | // We also need to be able to generate multiple views of a log file depending on |
| 52 | // the target. |
| 53 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 54 | // Replays all the channels in the logfile to the event loop. |
| 55 | class LogReader { |
| 56 | public: |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 57 | // If you want to supply a new configuration that will be used for replay |
| 58 | // (e.g., to change message rates, or to populate an updated schema), then |
| 59 | // pass it in here. It must provide all the channels that the original logged |
| 60 | // config did. |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 61 | // |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 62 | // The single file constructor calls SortParts internally. |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 63 | LogReader(std::string_view filename, |
| 64 | const Configuration *replay_configuration = nullptr); |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 65 | LogReader(std::vector<LogFile> log_files, |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 66 | const Configuration *replay_configuration = nullptr); |
James Kuszmaul | 7daef36 | 2019-12-31 18:28:17 -0800 | [diff] [blame] | 67 | ~LogReader(); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 68 | |
Austin Schuh | 6331ef9 | 2020-01-07 18:28:09 -0800 | [diff] [blame] | 69 | // Registers all the callbacks to send the log file data out on an event loop |
| 70 | // created in event_loop_factory. This also updates time to be at the start |
| 71 | // of the log file by running until the log file starts. |
| 72 | // Note: the configuration used in the factory should be configuration() |
| 73 | // below, but can be anything as long as the locations needed to send |
| 74 | // everything are available. |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 75 | void Register(SimulatedEventLoopFactory *event_loop_factory); |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 76 | // Registers all the callbacks to send the log file data out to an event loop |
| 77 | // factory. This does not start replaying or change the current distributed |
| 78 | // time of the factory. It does change the monotonic clocks to be right. |
| 79 | void RegisterWithoutStarting(SimulatedEventLoopFactory *event_loop_factory); |
Austin Schuh | 6331ef9 | 2020-01-07 18:28:09 -0800 | [diff] [blame] | 80 | // Creates an SimulatedEventLoopFactory accessible via event_loop_factory(), |
| 81 | // and then calls Register. |
| 82 | void Register(); |
| 83 | // Registers callbacks for all the events after the log file starts. This is |
| 84 | // only useful when replaying live. |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 85 | void Register(EventLoop *event_loop); |
Austin Schuh | 6331ef9 | 2020-01-07 18:28:09 -0800 | [diff] [blame] | 86 | |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 87 | // Called whenever a log file starts for a node. |
| 88 | void OnStart(std::function<void()> fn); |
| 89 | void OnStart(const Node *node, std::function<void()> fn); |
| 90 | // Called whenever a log file ends for a node. |
| 91 | void OnEnd(std::function<void()> fn); |
| 92 | void OnEnd(const Node *node, std::function<void()> fn); |
| 93 | |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 94 | // Unregisters the senders. You only need to call this if you separately |
| 95 | // supplied an event loop or event loop factory and the lifetimes are such |
| 96 | // that they need to be explicitly destroyed before the LogReader destructor |
| 97 | // gets called. |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 98 | void Deregister(); |
| 99 | |
Austin Schuh | 0c29701 | 2020-09-16 18:41:59 -0700 | [diff] [blame] | 100 | // Returns the configuration being used for replay from the log file. |
| 101 | // Note that this may be different from the configuration actually used for |
| 102 | // handling events. You should generally only use this to create a |
| 103 | // SimulatedEventLoopFactory, and then get the configuration from there for |
| 104 | // everything else. |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 105 | const Configuration *logged_configuration() const; |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 106 | // Returns the configuration being used for replay from the log file. |
| 107 | // Note that this may be different from the configuration actually used for |
| 108 | // handling events. You should generally only use this to create a |
| 109 | // SimulatedEventLoopFactory, and then get the configuration from there for |
| 110 | // everything else. |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 111 | // The pointer is invalidated whenever RemapLoggedChannel is called. |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 112 | const Configuration *configuration() const; |
| 113 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 114 | // Returns the nodes that this log file was created on. This is a list of |
Austin Schuh | 0767662 | 2021-01-21 18:59:17 -0800 | [diff] [blame] | 115 | // pointers to a node in the nodes() list inside logged_configuration(). |
| 116 | std::vector<const Node *> LoggedNodes() const; |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 117 | |
| 118 | // Returns the starting timestamp for the log file. |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 119 | monotonic_clock::time_point monotonic_start_time( |
| 120 | const Node *node = nullptr) const; |
| 121 | realtime_clock::time_point realtime_start_time( |
| 122 | const Node *node = nullptr) const; |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 123 | |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 124 | // Causes the logger to publish the provided channel on a different name so |
| 125 | // that replayed applications can publish on the proper channel name without |
| 126 | // interference. This operates on raw channel names, without any node or |
| 127 | // application specific mappings. |
| 128 | void RemapLoggedChannel(std::string_view name, std::string_view type, |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 129 | std::string_view add_prefix = "/original", |
| 130 | std::string_view new_type = ""); |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 131 | template <typename T> |
| 132 | void RemapLoggedChannel(std::string_view name, |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 133 | std::string_view add_prefix = "/original", |
| 134 | std::string_view new_type = "") { |
| 135 | RemapLoggedChannel(name, T::GetFullyQualifiedName(), add_prefix, new_type); |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 136 | } |
| 137 | |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 138 | // Remaps the provided channel, though this respects node mappings, and |
| 139 | // preserves them too. This makes it so if /aos -> /pi1/aos on one node, |
| 140 | // /original/aos -> /original/pi1/aos on the same node after renaming, just |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 141 | // like you would hope. If new_type is not empty, the new channel will use |
| 142 | // the provided type instead. This allows for renaming messages. |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 143 | // |
| 144 | // TODO(austin): If you have 2 nodes remapping something to the same channel, |
| 145 | // this doesn't handle that. No use cases exist yet for that, so it isn't |
| 146 | // being done yet. |
| 147 | void RemapLoggedChannel(std::string_view name, std::string_view type, |
| 148 | const Node *node, |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 149 | std::string_view add_prefix = "/original", |
| 150 | std::string_view new_type = ""); |
Brian Silverman | de9f3ff | 2020-04-28 16:56:58 -0700 | [diff] [blame] | 151 | template <typename T> |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 152 | void RemapLoggedChannel(std::string_view name, const Node *node, |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 153 | std::string_view add_prefix = "/original", |
| 154 | std::string_view new_type = "") { |
| 155 | RemapLoggedChannel(name, T::GetFullyQualifiedName(), node, add_prefix, |
| 156 | new_type); |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | template <typename T> |
| 160 | bool HasChannel(std::string_view name, const Node *node = nullptr) { |
Austin Schuh | 0ca51f3 | 2020-12-25 21:51:45 -0800 | [diff] [blame] | 161 | return configuration::GetChannel(logged_configuration(), name, |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 162 | T::GetFullyQualifiedName(), "", node, |
| 163 | true) != nullptr; |
Brian Silverman | de9f3ff | 2020-04-28 16:56:58 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Austin Schuh | 8252906 | 2021-12-08 12:09:52 -0800 | [diff] [blame] | 166 | template <typename T> |
| 167 | void MaybeRemapLoggedChannel(std::string_view name, |
| 168 | const Node *node = nullptr) { |
| 169 | if (HasChannel<T>(name, node)) { |
| 170 | RemapLoggedChannel<T>(name, node); |
| 171 | } |
| 172 | } |
| 173 | |
James Kuszmaul | 4f106fb | 2021-01-05 20:53:02 -0800 | [diff] [blame] | 174 | // Returns true if the channel exists on the node and was logged. |
| 175 | template <typename T> |
| 176 | bool HasLoggedChannel(std::string_view name, const Node *node = nullptr) { |
Austin Schuh | 5ee5687 | 2021-01-30 16:53:34 -0800 | [diff] [blame] | 177 | const Channel *channel = |
| 178 | configuration::GetChannel(logged_configuration(), name, |
| 179 | T::GetFullyQualifiedName(), "", node, true); |
James Kuszmaul | 4f106fb | 2021-01-05 20:53:02 -0800 | [diff] [blame] | 180 | if (channel == nullptr) return false; |
| 181 | return channel->logger() != LoggerConfig::NOT_LOGGED; |
| 182 | } |
| 183 | |
Austin Schuh | 1c22735 | 2021-09-17 12:53:54 -0700 | [diff] [blame] | 184 | // Returns a list of all the original channels from remapping. |
| 185 | std::vector<const Channel *> RemappedChannels() const; |
| 186 | |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 187 | SimulatedEventLoopFactory *event_loop_factory() { |
| 188 | return event_loop_factory_; |
| 189 | } |
| 190 | |
Austin Schuh | 0ca51f3 | 2020-12-25 21:51:45 -0800 | [diff] [blame] | 191 | std::string_view name() const { return log_files_[0].name; } |
Austin Schuh | 0c29701 | 2020-09-16 18:41:59 -0700 | [diff] [blame] | 192 | |
James Kuszmaul | 71a8193 | 2020-12-15 21:08:01 -0800 | [diff] [blame] | 193 | // Set whether to exit the SimulatedEventLoopFactory when we finish reading |
| 194 | // the logfile. |
| 195 | void set_exit_on_finish(bool exit_on_finish) { |
| 196 | exit_on_finish_ = exit_on_finish; |
| 197 | } |
| 198 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 199 | private: |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 200 | void Register(EventLoop *event_loop, const Node *node); |
| 201 | |
| 202 | void RegisterDuringStartup(EventLoop *event_loop, const Node *node); |
| 203 | |
| 204 | const Channel *RemapChannel(const EventLoop *event_loop, const Node *node, |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 205 | const Channel *channel); |
| 206 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 207 | // Queues at least max_out_of_order_duration_ messages into channels_. |
| 208 | void QueueMessages(); |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 209 | // Handle constructing a configuration with all the additional remapped |
| 210 | // channels from calls to RemapLoggedChannel. |
| 211 | void MakeRemappedConfig(); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 212 | |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 213 | // Returns the number of nodes. |
| 214 | size_t nodes_count() const { |
| 215 | return !configuration::MultiNode(logged_configuration()) |
| 216 | ? 1u |
| 217 | : logged_configuration()->nodes()->size(); |
| 218 | } |
| 219 | |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 220 | const std::vector<LogFile> log_files_; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 221 | |
Austin Schuh | 969cd60 | 2021-01-03 00:09:45 -0800 | [diff] [blame] | 222 | // Class to manage sending RemoteMessages on the provided node after the |
| 223 | // correct delay. |
Austin Schuh | 5ee5687 | 2021-01-30 16:53:34 -0800 | [diff] [blame] | 224 | class RemoteMessageSender { |
Austin Schuh | 969cd60 | 2021-01-03 00:09:45 -0800 | [diff] [blame] | 225 | public: |
| 226 | RemoteMessageSender(aos::Sender<message_bridge::RemoteMessage> sender, |
| 227 | EventLoop *event_loop); |
| 228 | RemoteMessageSender(RemoteMessageSender const &) = delete; |
| 229 | RemoteMessageSender &operator=(RemoteMessageSender const &) = delete; |
| 230 | |
| 231 | // Sends the provided message. If monotonic_timestamp_time is min_time, |
| 232 | // send it immediately. |
| 233 | void Send( |
| 234 | FlatbufferDetachedBuffer<message_bridge::RemoteMessage> remote_message, |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 235 | BootTimestamp monotonic_timestamp_time, size_t source_boot_count); |
Austin Schuh | 969cd60 | 2021-01-03 00:09:45 -0800 | [diff] [blame] | 236 | |
| 237 | private: |
| 238 | // Handles actually sending the timestamp if we were delayed. |
| 239 | void SendTimestamp(); |
| 240 | // Handles scheduling the timer to send at the correct time. |
| 241 | void ScheduleTimestamp(); |
| 242 | |
| 243 | EventLoop *event_loop_; |
| 244 | aos::Sender<message_bridge::RemoteMessage> sender_; |
| 245 | aos::TimerHandler *timer_; |
| 246 | |
| 247 | // Time we are scheduled for, or min_time if we aren't scheduled. |
| 248 | monotonic_clock::time_point scheduled_time_ = monotonic_clock::min_time; |
| 249 | |
| 250 | struct Timestamp { |
| 251 | Timestamp(FlatbufferDetachedBuffer<message_bridge::RemoteMessage> |
| 252 | new_remote_message, |
| 253 | monotonic_clock::time_point new_monotonic_timestamp_time) |
| 254 | : remote_message(std::move(new_remote_message)), |
| 255 | monotonic_timestamp_time(new_monotonic_timestamp_time) {} |
| 256 | FlatbufferDetachedBuffer<message_bridge::RemoteMessage> remote_message; |
| 257 | monotonic_clock::time_point monotonic_timestamp_time; |
| 258 | }; |
| 259 | |
| 260 | // List of messages to send. The timer works through them and then disables |
| 261 | // itself automatically. |
| 262 | std::deque<Timestamp> remote_timestamps_; |
| 263 | }; |
| 264 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 265 | // State per node. |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 266 | class State { |
| 267 | public: |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 268 | State(std::unique_ptr<TimestampMapper> timestamp_mapper, const Node *node); |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 269 | |
| 270 | // Connects up the timestamp mappers. |
| 271 | void AddPeer(State *peer); |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 272 | |
Austin Schuh | e639ea1 | 2021-01-25 13:00:22 -0800 | [diff] [blame] | 273 | TimestampMapper *timestamp_mapper() { return timestamp_mapper_.get(); } |
| 274 | |
Austin Schuh | dda74ec | 2021-01-03 19:30:37 -0800 | [diff] [blame] | 275 | // Returns the next sorted message with all the timestamps extracted and |
| 276 | // matched. |
| 277 | TimestampedMessage PopOldest(); |
Austin Schuh | 188eabe | 2020-12-29 23:41:13 -0800 | [diff] [blame] | 278 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 279 | // Returns the monotonic time of the oldest message. |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 280 | BootTimestamp OldestMessageTime() const; |
| 281 | |
| 282 | size_t boot_count() const { |
| 283 | // If we are replaying directly into an event loop, we can't reboot. So |
| 284 | // we will stay stuck on the 0th boot. |
| 285 | if (!node_event_loop_factory_) return 0u; |
| 286 | return node_event_loop_factory_->boot_count(); |
| 287 | } |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 288 | |
| 289 | // Primes the queues inside State. Should be called before calling |
| 290 | // OldestMessageTime. |
| 291 | void SeedSortedMessages(); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 292 | |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 293 | void SetupStartupTimer() { |
| 294 | const monotonic_clock::time_point start_time = |
| 295 | monotonic_start_time(boot_count()); |
| 296 | if (start_time == monotonic_clock::min_time) { |
| 297 | LOG(ERROR) |
| 298 | << "No start time, skipping, please figure out when this happens"; |
| 299 | RunOnStart(); |
| 300 | return; |
| 301 | } |
James Kuszmaul | 57d3974 | 2021-10-15 20:07:34 -0700 | [diff] [blame] | 302 | CHECK_GE(start_time, event_loop_->monotonic_now()); |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 303 | startup_timer_->Setup(start_time); |
| 304 | } |
| 305 | |
| 306 | void set_startup_timer(TimerHandler *timer_handler) { |
| 307 | startup_timer_ = timer_handler; |
| 308 | if (startup_timer_) { |
| 309 | if (event_loop_->node() != nullptr) { |
| 310 | startup_timer_->set_name(absl::StrCat( |
| 311 | event_loop_->node()->name()->string_view(), "_startup")); |
| 312 | } else { |
| 313 | startup_timer_->set_name("startup"); |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 318 | // Returns the starting time for this node. |
Austin Schuh | 2dc8c7d | 2021-07-01 17:41:28 -0700 | [diff] [blame] | 319 | monotonic_clock::time_point monotonic_start_time(size_t boot_count) const { |
| 320 | return timestamp_mapper_ |
| 321 | ? timestamp_mapper_->monotonic_start_time(boot_count) |
| 322 | : monotonic_clock::min_time; |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 323 | } |
Austin Schuh | 2dc8c7d | 2021-07-01 17:41:28 -0700 | [diff] [blame] | 324 | realtime_clock::time_point realtime_start_time(size_t boot_count) const { |
| 325 | return timestamp_mapper_ |
| 326 | ? timestamp_mapper_->realtime_start_time(boot_count) |
| 327 | : realtime_clock::min_time; |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | // Sets the node event loop factory for replaying into a |
| 331 | // SimulatedEventLoopFactory. Returns the EventLoop to use. |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 332 | void SetNodeEventLoopFactory(NodeEventLoopFactory *node_event_loop_factory); |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 333 | |
| 334 | // Sets and gets the event loop to use. |
| 335 | void set_event_loop(EventLoop *event_loop) { event_loop_ = event_loop; } |
| 336 | EventLoop *event_loop() { return event_loop_; } |
| 337 | |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 338 | const Node *node() const { return node_; } |
| 339 | |
| 340 | void Register(EventLoop *event_loop); |
| 341 | |
| 342 | void OnStart(std::function<void()> fn); |
| 343 | void OnEnd(std::function<void()> fn); |
| 344 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 345 | // Sets the current realtime offset from the monotonic clock for this node |
| 346 | // (if we are on a simulated event loop). |
| 347 | void SetRealtimeOffset(monotonic_clock::time_point monotonic_time, |
| 348 | realtime_clock::time_point realtime_time) { |
| 349 | if (node_event_loop_factory_ != nullptr) { |
| 350 | node_event_loop_factory_->SetRealtimeOffset(monotonic_time, |
| 351 | realtime_time); |
| 352 | } |
| 353 | } |
| 354 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 355 | // Returns the MessageHeader sender to log delivery timestamps to for the |
| 356 | // provided remote node. |
Austin Schuh | 61e973f | 2021-02-21 21:43:56 -0800 | [diff] [blame] | 357 | RemoteMessageSender *RemoteTimestampSender(const Channel *channel, |
| 358 | const Connection *connection); |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 359 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 360 | // Converts a timestamp from the monotonic clock on this node to the |
| 361 | // distributed clock. |
| 362 | distributed_clock::time_point ToDistributedClock( |
| 363 | monotonic_clock::time_point time) { |
| 364 | return node_event_loop_factory_->ToDistributedClock(time); |
| 365 | } |
| 366 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 367 | // Returns the current time on the remote node which sends messages on |
| 368 | // channel_index. |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 369 | BootTimestamp monotonic_remote_now(size_t channel_index) { |
| 370 | State *s = channel_source_state_[channel_index]; |
| 371 | return BootTimestamp{ |
| 372 | .boot = s->boot_count(), |
| 373 | .time = s->node_event_loop_factory_->monotonic_now()}; |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Austin Schuh | 5ee5687 | 2021-01-30 16:53:34 -0800 | [diff] [blame] | 376 | // Returns the start time of the remote for the provided channel. |
| 377 | monotonic_clock::time_point monotonic_remote_start_time( |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 378 | size_t boot_count, size_t channel_index) { |
Austin Schuh | 2dc8c7d | 2021-07-01 17:41:28 -0700 | [diff] [blame] | 379 | return channel_source_state_[channel_index]->monotonic_start_time( |
| 380 | boot_count); |
Austin Schuh | 5ee5687 | 2021-01-30 16:53:34 -0800 | [diff] [blame] | 381 | } |
| 382 | |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 383 | void DestroyEventLoop() { event_loop_unique_ptr_.reset(); } |
| 384 | |
| 385 | EventLoop *MakeEventLoop() { |
| 386 | CHECK(!event_loop_unique_ptr_); |
| 387 | event_loop_unique_ptr_ = |
| 388 | node_event_loop_factory_->MakeEventLoop("log_reader"); |
| 389 | return event_loop_unique_ptr_.get(); |
| 390 | } |
| 391 | |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 392 | distributed_clock::time_point RemoteToDistributedClock( |
| 393 | size_t channel_index, monotonic_clock::time_point time) { |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 394 | return channel_source_state_[channel_index] |
| 395 | ->node_event_loop_factory_->ToDistributedClock(time); |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | const Node *remote_node(size_t channel_index) { |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 399 | return channel_source_state_[channel_index] |
| 400 | ->node_event_loop_factory_->node(); |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Stephan Pleines | 559fa6c | 2022-01-06 17:23:51 -0800 | [diff] [blame^] | 403 | monotonic_clock::time_point monotonic_now() const { |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 404 | return node_event_loop_factory_->monotonic_now(); |
| 405 | } |
| 406 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 407 | // Sets the number of channels. |
| 408 | void SetChannelCount(size_t count); |
| 409 | |
| 410 | // Sets the sender, filter, and target factory for a channel. |
Austin Schuh | 969cd60 | 2021-01-03 00:09:45 -0800 | [diff] [blame] | 411 | void SetChannel(size_t logged_channel_index, size_t factory_channel_index, |
| 412 | std::unique_ptr<RawSender> sender, |
| 413 | message_bridge::NoncausalOffsetEstimator *filter, |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 414 | bool is_forwarded, State *source_state); |
| 415 | |
| 416 | void SetRemoteTimestampSender(size_t logged_channel_index, |
| 417 | RemoteMessageSender *remote_timestamp_sender); |
| 418 | |
| 419 | void RunOnStart(); |
| 420 | void RunOnEnd(); |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 421 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 422 | // Unregisters everything so we can destory the event loop. |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 423 | // TODO(austin): Is this needed? OnShutdown should be able to serve this |
| 424 | // need. |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 425 | void Deregister(); |
| 426 | |
| 427 | // Sets the current TimerHandle for the replay callback. |
| 428 | void set_timer_handler(TimerHandler *timer_handler) { |
| 429 | timer_handler_ = timer_handler; |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 430 | if (timer_handler_) { |
| 431 | if (event_loop_->node() != nullptr) { |
| 432 | timer_handler_->set_name(absl::StrCat( |
| 433 | event_loop_->node()->name()->string_view(), "_main")); |
| 434 | } else { |
| 435 | timer_handler_->set_name("main"); |
| 436 | } |
| 437 | } |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | // Sets the next wakeup time on the replay callback. |
| 441 | void Setup(monotonic_clock::time_point next_time) { |
| 442 | timer_handler_->Setup(next_time); |
| 443 | } |
| 444 | |
| 445 | // Sends a buffer on the provided channel index. |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 446 | bool Send(const TimestampedMessage ×tamped_message); |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 447 | |
| 448 | // Returns a debug string for the channel merger. |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 449 | std::string DebugString() const { |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 450 | if (!timestamp_mapper_) { |
Austin Schuh | e639ea1 | 2021-01-25 13:00:22 -0800 | [diff] [blame] | 451 | return ""; |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 452 | } |
Austin Schuh | e639ea1 | 2021-01-25 13:00:22 -0800 | [diff] [blame] | 453 | return timestamp_mapper_->DebugString(); |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 454 | } |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 455 | |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 456 | void ClearRemoteTimestampSenders() { |
| 457 | channel_timestamp_loggers_.clear(); |
| 458 | timestamp_loggers_.clear(); |
| 459 | } |
| 460 | |
Austin Schuh | bd5f74a | 2021-11-11 20:55:38 -0800 | [diff] [blame] | 461 | void SetFoundLastMessage(bool val) { |
| 462 | found_last_message_ = val; |
| 463 | last_message_.resize(factory_channel_index_.size(), false); |
| 464 | } |
| 465 | bool found_last_message() const { return found_last_message_; } |
| 466 | |
| 467 | void set_last_message(size_t channel_index) { |
| 468 | CHECK_LT(channel_index, last_message_.size()); |
| 469 | last_message_[channel_index] = true; |
| 470 | } |
| 471 | |
| 472 | bool last_message(size_t channel_index) { |
| 473 | CHECK_LT(channel_index, last_message_.size()); |
| 474 | return last_message_[channel_index]; |
| 475 | } |
| 476 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 477 | private: |
| 478 | // Log file. |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 479 | std::unique_ptr<TimestampMapper> timestamp_mapper_; |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 480 | |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 481 | // Senders. |
| 482 | std::vector<std::unique_ptr<RawSender>> channels_; |
Austin Schuh | 969cd60 | 2021-01-03 00:09:45 -0800 | [diff] [blame] | 483 | std::vector<RemoteMessageSender *> remote_timestamp_senders_; |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 484 | // The mapping from logged channel index to sent channel index. Needed for |
| 485 | // sending out MessageHeaders. |
| 486 | std::vector<int> factory_channel_index_; |
| 487 | |
Austin Schuh | 9942bae | 2021-01-07 22:06:44 -0800 | [diff] [blame] | 488 | struct ContiguousSentTimestamp { |
| 489 | // Most timestamps make it through the network, so it saves a ton of |
| 490 | // memory and CPU to store the start and end, and search for valid ranges. |
| 491 | // For one of the logs I looked at, we had 2 ranges for 4 days. |
| 492 | // |
| 493 | // Save monotonic times as well to help if a queue index ever wraps. Odds |
| 494 | // are very low, but doesn't hurt. |
| 495 | // |
| 496 | // The starting time and matching queue index. |
| 497 | monotonic_clock::time_point starting_monotonic_event_time = |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 498 | monotonic_clock::min_time; |
Austin Schuh | 9942bae | 2021-01-07 22:06:44 -0800 | [diff] [blame] | 499 | uint32_t starting_queue_index = 0xffffffff; |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 500 | |
Austin Schuh | 9942bae | 2021-01-07 22:06:44 -0800 | [diff] [blame] | 501 | // Ending time and queue index. |
| 502 | monotonic_clock::time_point ending_monotonic_event_time = |
| 503 | monotonic_clock::max_time; |
| 504 | uint32_t ending_queue_index = 0xffffffff; |
| 505 | |
| 506 | // The queue index that the first message was *actually* sent with. The |
| 507 | // queue indices are assumed to be contiguous through this range. |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 508 | uint32_t actual_queue_index = 0xffffffff; |
| 509 | }; |
| 510 | |
| 511 | // Stores all the timestamps that have been sent on this channel. This is |
| 512 | // only done for channels which are forwarded and on the node which |
Austin Schuh | 9942bae | 2021-01-07 22:06:44 -0800 | [diff] [blame] | 513 | // initially sends the message. Compress using ranges and offsets. |
| 514 | std::vector<std::unique_ptr<std::vector<ContiguousSentTimestamp>>> |
| 515 | queue_index_map_; |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 516 | |
| 517 | // Factory (if we are in sim) that this loop was created on. |
| 518 | NodeEventLoopFactory *node_event_loop_factory_ = nullptr; |
| 519 | std::unique_ptr<EventLoop> event_loop_unique_ptr_; |
| 520 | // Event loop. |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 521 | const Node *node_ = nullptr; |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 522 | EventLoop *event_loop_ = nullptr; |
| 523 | // And timer used to send messages. |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 524 | TimerHandler *timer_handler_ = nullptr; |
| 525 | TimerHandler *startup_timer_ = nullptr; |
Austin Schuh | 858c9f3 | 2020-08-31 16:56:12 -0700 | [diff] [blame] | 526 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 527 | // Filters (or nullptr if it isn't a forwarded channel) for each channel. |
| 528 | // This corresponds to the object which is shared among all the channels |
| 529 | // going between 2 nodes. The second element in the tuple indicates if this |
| 530 | // is the primary direction or not. |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 531 | std::vector<message_bridge::NoncausalOffsetEstimator *> filters_; |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 532 | |
| 533 | // List of NodeEventLoopFactorys (or nullptr if it isn't a forwarded |
| 534 | // channel) which correspond to the originating node. |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 535 | std::vector<State *> channel_source_state_; |
| 536 | |
Austin Schuh | 61e973f | 2021-02-21 21:43:56 -0800 | [diff] [blame] | 537 | // This is a cache for channel, connection mapping to the corresponding |
| 538 | // sender. |
| 539 | absl::btree_map<std::pair<const Channel *, const Connection *>, |
| 540 | std::shared_ptr<RemoteMessageSender>> |
| 541 | channel_timestamp_loggers_; |
| 542 | |
| 543 | // Mapping from resolved RemoteMessage channel to RemoteMessage sender. This |
| 544 | // is the channel that timestamps are published to. |
| 545 | absl::btree_map<const Channel *, std::shared_ptr<RemoteMessageSender>> |
| 546 | timestamp_loggers_; |
Austin Schuh | 58646e2 | 2021-08-23 23:51:46 -0700 | [diff] [blame] | 547 | |
| 548 | std::vector<std::function<void()>> on_starts_; |
| 549 | std::vector<std::function<void()>> on_ends_; |
| 550 | |
| 551 | bool stopped_ = false; |
| 552 | bool started_ = false; |
Austin Schuh | bd5f74a | 2021-11-11 20:55:38 -0800 | [diff] [blame] | 553 | |
| 554 | bool found_last_message_ = false; |
| 555 | std::vector<bool> last_message_; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 556 | }; |
| 557 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 558 | // Node index -> State. |
| 559 | std::vector<std::unique_ptr<State>> states_; |
| 560 | |
| 561 | // Creates the requested filter if it doesn't exist, regardless of whether |
| 562 | // these nodes can actually communicate directly. The second return value |
| 563 | // reports if this is the primary direction or not. |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 564 | message_bridge::NoncausalOffsetEstimator *GetFilter(const Node *node_a, |
| 565 | const Node *node_b); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 566 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 567 | // List of filters for a connection. The pointer to the first node will be |
| 568 | // less than the second node. |
Austin Schuh | 0ca1fd3 | 2020-12-18 22:53:05 -0800 | [diff] [blame] | 569 | std::unique_ptr<message_bridge::MultiNodeNoncausalOffsetEstimator> filters_; |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 570 | |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 571 | std::unique_ptr<FlatbufferDetachedBuffer<Configuration>> |
| 572 | remapped_configuration_buffer_; |
| 573 | |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 574 | std::unique_ptr<SimulatedEventLoopFactory> event_loop_factory_unique_ptr_; |
| 575 | SimulatedEventLoopFactory *event_loop_factory_ = nullptr; |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 576 | |
| 577 | // Map of channel indices to new name. The channel index will be an index into |
| 578 | // logged_configuration(), and the string key will be the name of the channel |
| 579 | // to send on instead of the logged channel name. |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 580 | struct RemappedChannel { |
| 581 | std::string remapped_name; |
| 582 | std::string new_type; |
| 583 | }; |
| 584 | std::map<size_t, RemappedChannel> remapped_channels_; |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 585 | std::vector<MapT> maps_; |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 586 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 587 | // Number of nodes which still have data to send. This is used to figure out |
| 588 | // when to exit. |
| 589 | size_t live_nodes_ = 0; |
| 590 | |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 591 | const Configuration *remapped_configuration_ = nullptr; |
| 592 | const Configuration *replay_configuration_ = nullptr; |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 593 | |
| 594 | // If true, the replay timer will ignore any missing data. This is used |
| 595 | // during startup when we are bootstrapping everything and trying to get to |
| 596 | // the start of all the log files. |
| 597 | bool ignore_missing_data_ = false; |
James Kuszmaul | 71a8193 | 2020-12-15 21:08:01 -0800 | [diff] [blame] | 598 | |
| 599 | // Whether to exit the SimulatedEventLoop when we finish reading the logs. |
| 600 | bool exit_on_finish_ = true; |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 601 | }; |
| 602 | |
| 603 | } // namespace logger |
| 604 | } // namespace aos |
| 605 | |
Austin Schuh | b06f03b | 2021-02-17 22:00:37 -0800 | [diff] [blame] | 606 | #endif // AOS_EVENTS_LOGGING_LOG_READER_H_ |