metadatalogapi.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #define NETDATA_RRD_INTERNALS
  3. #include "metadatalog.h"
  4. /*
  5. * Returns 0 on success, negative on error
  6. */
  7. int metalog_init(struct rrdengine_instance *rrdeng_parent_ctx)
  8. {
  9. struct metalog_instance *ctx;
  10. int error;
  11. ctx = callocz(1, sizeof(*ctx));
  12. ctx->initialized = 0;
  13. rrdeng_parent_ctx->metalog_ctx = ctx;
  14. ctx->rrdeng_ctx = rrdeng_parent_ctx;
  15. error = init_metalog_files(ctx);
  16. if (error) {
  17. goto error_after_init_rrd_files;
  18. }
  19. ctx->initialized = 1; /* notify dbengine that the metadata log has finished initializing */
  20. return 0;
  21. error_after_init_rrd_files:
  22. freez(ctx);
  23. return UV_EIO;
  24. }
  25. /* This function is called by dbengine rotation logic when the metric has no writers */
  26. void metalog_delete_dimension_by_uuid(struct metalog_instance *ctx, uuid_t *metric_uuid)
  27. {
  28. uuid_t multihost_uuid;
  29. delete_dimension_uuid(metric_uuid);
  30. rrdeng_convert_legacy_uuid_to_multihost(ctx->rrdeng_ctx->machine_guid, metric_uuid, &multihost_uuid);
  31. delete_dimension_uuid(&multihost_uuid);
  32. }