event_helpers.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #pragma once
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "db/column_family.h"
  10. #include "db/version_edit.h"
  11. #include "logging/event_logger.h"
  12. #include "rocksdb/listener.h"
  13. #include "rocksdb/table_properties.h"
  14. namespace ROCKSDB_NAMESPACE {
  15. class EventHelpers {
  16. public:
  17. static void AppendCurrentTime(JSONWriter* json_writer);
  18. static void NotifyTableFileCreationStarted(
  19. const std::vector<std::shared_ptr<EventListener>>& listeners,
  20. const std::string& db_name, const std::string& cf_name,
  21. const std::string& file_path, int job_id, TableFileCreationReason reason);
  22. static void NotifyOnBackgroundError(
  23. const std::vector<std::shared_ptr<EventListener>>& listeners,
  24. BackgroundErrorReason reason, Status* bg_error,
  25. InstrumentedMutex* db_mutex, bool* auto_recovery);
  26. static void LogAndNotifyTableFileCreationFinished(
  27. EventLogger* event_logger,
  28. const std::vector<std::shared_ptr<EventListener>>& listeners,
  29. const std::string& db_name, const std::string& cf_name,
  30. const std::string& file_path, int job_id, const FileDescriptor& fd,
  31. uint64_t oldest_blob_file_number, const TableProperties& table_properties,
  32. TableFileCreationReason reason, const Status& s,
  33. const std::string& file_checksum,
  34. const std::string& file_checksum_func_name);
  35. static void LogAndNotifyTableFileDeletion(
  36. EventLogger* event_logger, int job_id, uint64_t file_number,
  37. const std::string& file_path, const Status& status,
  38. const std::string& db_name,
  39. const std::vector<std::shared_ptr<EventListener>>& listeners);
  40. static void NotifyOnErrorRecoveryEnd(
  41. const std::vector<std::shared_ptr<EventListener>>& listeners,
  42. const Status& old_bg_error, const Status& new_bg_error,
  43. InstrumentedMutex* db_mutex);
  44. static void NotifyBlobFileCreationStarted(
  45. const std::vector<std::shared_ptr<EventListener>>& listeners,
  46. const std::string& db_name, const std::string& cf_name,
  47. const std::string& file_path, int job_id,
  48. BlobFileCreationReason creation_reason);
  49. static void LogAndNotifyBlobFileCreationFinished(
  50. EventLogger* event_logger,
  51. const std::vector<std::shared_ptr<EventListener>>& listeners,
  52. const std::string& db_name, const std::string& cf_name,
  53. const std::string& file_path, int job_id, uint64_t file_number,
  54. BlobFileCreationReason creation_reason, const Status& s,
  55. const std::string& file_checksum,
  56. const std::string& file_checksum_func_name, uint64_t total_blob_count,
  57. uint64_t total_blob_bytes);
  58. static void LogAndNotifyBlobFileDeletion(
  59. EventLogger* event_logger,
  60. const std::vector<std::shared_ptr<EventListener>>& listeners, int job_id,
  61. uint64_t file_number, const std::string& file_path, const Status& status,
  62. const std::string& db_name);
  63. private:
  64. static void LogAndNotifyTableFileCreation(
  65. EventLogger* event_logger,
  66. const std::vector<std::shared_ptr<EventListener>>& listeners,
  67. const FileDescriptor& fd, const TableFileCreationInfo& info);
  68. };
  69. } // namespace ROCKSDB_NAMESPACE