thread_status_updater_debug.cc 1.3 KB

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