logfile.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_LOGFILE_H
  3. #define NETDATA_LOGFILE_H
  4. #include "metadatalogprotocol.h"
  5. #include "../rrdengine.h"
  6. /* Forward declarations */
  7. struct metadata_logfile;
  8. struct metalog_worker_config;
  9. #define METALOG_PREFIX "metadatalog-"
  10. #define METALOG_EXTENSION ".mlf"
  11. /* only one event loop is supported for now */
  12. struct metadata_logfile {
  13. unsigned fileno; /* Starts at 1 */
  14. unsigned starting_fileno; /* 0 for normal files, staring number during compaction */
  15. uv_file file;
  16. uint64_t pos;
  17. struct metalog_instance *ctx;
  18. struct metadata_logfile *next;
  19. };
  20. struct metadata_logfile_list {
  21. struct metadata_logfile *first; /* oldest */
  22. struct metadata_logfile *last; /* newest */
  23. };
  24. extern void generate_metadata_logfile_path(struct metadata_logfile *metadatalog, char *str, size_t maxlen);
  25. extern int rename_metadata_logfile(struct metadata_logfile *metalogfile, unsigned new_starting_fileno,
  26. unsigned new_fileno);
  27. extern int unlink_metadata_logfile(struct metadata_logfile *metalogfile);
  28. extern int load_metadata_logfile(struct metalog_instance *ctx, struct metadata_logfile *logfile);
  29. extern int init_metalog_files(struct metalog_instance *ctx);
  30. #endif /* NETDATA_LOGFILE_H */