1.14. Saving and restoring the statistics data¶
Fast DDS Statistics Backend allows to dump the contents of the database to the file system. This may be used as a backup procedure, or as a means of analyzing the data offline later. It is also possible to load a dump previously saved, which allows for this analysis to be done with any front-end that communicates with the Fast DDS Statistics Backend.
dump_database()to save the content of the Backend’s database to a file.
load_database()to loaded a saved database to the Backend.
For information about the format of the dumped data, please, refer to Database dumps.
Loading a saved database can only be done on an empty Backend.
This means that no monitors were initialized since the Backend started,
or that the Backend has been reset using
load_database() is used on a non-empty Backend,
an exception will be issued.
The following snippet shows how to dump the current database contents to a file, and then load another data set that was saved previously, resetting the Backend in between.
// Save the database to a file StatisticsBackend::dump_database("new_backend_dump.json", false); // Reset the Backend to empty the current database contents StatisticsBackend::reset(); // Load an old backup to the emptied Backend StatisticsBackend::load_database("old_backend_dump.json");
The bool parameter of
dump_database() indicates if the statistics data
of all entities must be cleared after the dump.
// Save the database to a file, cleaning the statistics data StatisticsBackend::dump_database("new_backend_dump.json", true);