metric.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef DBENGINE_METRIC_H
  2. #define DBENGINE_METRIC_H
  3. #include "../rrd.h"
  4. #define MRG_PARTITIONS 10
  5. typedef struct metric METRIC;
  6. typedef struct mrg MRG;
  7. typedef struct mrg_entry {
  8. uuid_t uuid;
  9. Word_t section;
  10. time_t first_time_s;
  11. time_t last_time_s;
  12. uint32_t latest_update_every_s;
  13. } MRG_ENTRY;
  14. struct mrg_statistics {
  15. size_t entries;
  16. size_t entries_referenced;
  17. size_t entries_with_retention;
  18. size_t size; // total memory used, with indexing
  19. size_t current_references;
  20. size_t additions;
  21. size_t additions_duplicate;
  22. size_t deletions;
  23. size_t delete_having_retention_or_referenced;
  24. size_t delete_misses;
  25. size_t search_hits;
  26. size_t search_misses;
  27. size_t writers;
  28. size_t writers_conflicts;
  29. };
  30. MRG *mrg_create(void);
  31. void mrg_destroy(MRG *mrg);
  32. METRIC *mrg_metric_dup(MRG *mrg, METRIC *metric);
  33. bool mrg_metric_release(MRG *mrg, METRIC *metric);
  34. METRIC *mrg_metric_add_and_acquire(MRG *mrg, MRG_ENTRY entry, bool *ret);
  35. METRIC *mrg_metric_get_and_acquire(MRG *mrg, uuid_t *uuid, Word_t section);
  36. bool mrg_metric_release_and_delete(MRG *mrg, METRIC *metric);
  37. Word_t mrg_metric_id(MRG *mrg, METRIC *metric);
  38. uuid_t *mrg_metric_uuid(MRG *mrg, METRIC *metric);
  39. Word_t mrg_metric_section(MRG *mrg, METRIC *metric);
  40. bool mrg_metric_set_first_time_s(MRG *mrg, METRIC *metric, time_t first_time_s);
  41. bool mrg_metric_set_first_time_s_if_bigger(MRG *mrg, METRIC *metric, time_t first_time_s);
  42. time_t mrg_metric_get_first_time_s(MRG *mrg, METRIC *metric);
  43. bool mrg_metric_set_clean_latest_time_s(MRG *mrg, METRIC *metric, time_t latest_time_s);
  44. bool mrg_metric_set_hot_latest_time_s(MRG *mrg, METRIC *metric, time_t latest_time_s);
  45. time_t mrg_metric_get_latest_time_s(MRG *mrg, METRIC *metric);
  46. bool mrg_metric_set_update_every(MRG *mrg, METRIC *metric, time_t update_every_s);
  47. bool mrg_metric_set_update_every_s_if_zero(MRG *mrg, METRIC *metric, time_t update_every_s);
  48. time_t mrg_metric_get_update_every_s(MRG *mrg, METRIC *metric);
  49. void mrg_metric_expand_retention(MRG *mrg, METRIC *metric, time_t first_time_s, time_t last_time_s, time_t update_every_s);
  50. void mrg_metric_get_retention(MRG *mrg, METRIC *metric, time_t *first_time_s, time_t *last_time_s, time_t *update_every_s);
  51. bool mrg_metric_zero_disk_retention(MRG *mrg __maybe_unused, METRIC *metric);
  52. bool mrg_metric_set_writer(MRG *mrg, METRIC *metric);
  53. bool mrg_metric_clear_writer(MRG *mrg, METRIC *metric);
  54. struct mrg_statistics mrg_get_statistics(MRG *mrg);
  55. size_t mrg_aral_structures(void);
  56. size_t mrg_aral_overhead(void);
  57. #endif // DBENGINE_METRIC_H