thread_status_updater_debug.cc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include <mutex>
  6. #include "db/column_family.h"
  7. #include "monitoring/thread_status_updater.h"
  8. namespace ROCKSDB_NAMESPACE {
  9. #ifndef NDEBUG
  10. #ifdef ROCKSDB_USING_THREAD_STATUS
  11. void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap(
  12. const std::vector<ColumnFamilyHandle*>& handles, bool check_exist) {
  13. std::unique_lock<std::mutex> lock(thread_list_mutex_);
  14. if (check_exist) {
  15. assert(cf_info_map_.size() == handles.size());
  16. }
  17. for (auto* handle : handles) {
  18. auto* cfd = reinterpret_cast<ColumnFamilyHandleImpl*>(handle)->cfd();
  19. auto iter __attribute__((__unused__)) = cf_info_map_.find(cfd);
  20. if (check_exist) {
  21. assert(iter != cf_info_map_.end());
  22. assert(iter->second.cf_name == cfd->GetName());
  23. } else {
  24. assert(iter == cf_info_map_.end());
  25. }
  26. }
  27. }
  28. #else
  29. void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap(
  30. const std::vector<ColumnFamilyHandle*>& /*handles*/, bool /*check_exist*/) {
  31. }
  32. #endif // ROCKSDB_USING_THREAD_STATUS
  33. #endif // !NDEBUG
  34. } // namespace ROCKSDB_NAMESPACE