event_helpers.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef ROCKSDB_LITE
  19. static void NotifyTableFileCreationStarted(
  20. const std::vector<std::shared_ptr<EventListener>>& listeners,
  21. const std::string& db_name, const std::string& cf_name,
  22. const std::string& file_path, int job_id, TableFileCreationReason reason);
  23. #endif // !ROCKSDB_LITE
  24. static void NotifyOnBackgroundError(
  25. const std::vector<std::shared_ptr<EventListener>>& listeners,
  26. BackgroundErrorReason reason, Status* bg_error,
  27. InstrumentedMutex* db_mutex, bool* auto_recovery);
  28. static void LogAndNotifyTableFileCreationFinished(
  29. EventLogger* event_logger,
  30. const std::vector<std::shared_ptr<EventListener>>& listeners,
  31. const std::string& db_name, const std::string& cf_name,
  32. const std::string& file_path, int job_id, const FileDescriptor& fd,
  33. uint64_t oldest_blob_file_number, const TableProperties& table_properties,
  34. TableFileCreationReason reason, const Status& s);
  35. static void LogAndNotifyTableFileDeletion(
  36. EventLogger* event_logger, int job_id,
  37. uint64_t file_number, const std::string& file_path,
  38. const Status& status, const std::string& db_name,
  39. const std::vector<std::shared_ptr<EventListener>>& listeners);
  40. static void NotifyOnErrorRecoveryCompleted(
  41. const std::vector<std::shared_ptr<EventListener>>& listeners,
  42. Status bg_error, InstrumentedMutex* db_mutex);
  43. private:
  44. static void LogAndNotifyTableFileCreation(
  45. EventLogger* event_logger,
  46. const std::vector<std::shared_ptr<EventListener>>& listeners,
  47. const FileDescriptor& fd, const TableFileCreationInfo& info);
  48. };
  49. } // namespace ROCKSDB_NAMESPACE