Add Radar Product Manager debug dump

- Allows visibility of currently loaded products
This commit is contained in:
Dan Paulat 2023-04-06 23:33:39 -05:00
parent 6e10ca88d5
commit 871cae68dd
5 changed files with 73 additions and 3 deletions

View file

@ -54,8 +54,8 @@ static const std::string kDefaultLevel3Product_ {"N0B"};
static constexpr std::chrono::seconds kRetryInterval_ {15};
static std::unordered_map<std::string, std::weak_ptr<RadarProductManager>>
instanceMap_;
static std::mutex instanceMutex_;
instanceMap_;
static std::shared_mutex instanceMutex_;
static std::unordered_map<std::string,
std::shared_ptr<types::RadarProductRecord>>
@ -276,6 +276,58 @@ void RadarProductManager::Cleanup()
}
}
void RadarProductManager::DumpRecords()
{
scwx::util::async(
[]
{
logger_->info("Record Dump");
std::shared_lock instanceLock {instanceMutex_};
for (auto& instance : instanceMap_)
{
auto radarProductManager = instance.second.lock();
if (radarProductManager != nullptr)
{
logger_->info(" {}", radarProductManager->radar_site()->id());
logger_->info(" Level 2");
{
std::shared_lock level2ProductLock {
radarProductManager->p->level2ProductRecordMutex_};
for (auto& record :
radarProductManager->p->level2ProductRecords_)
{
logger_->info(" {}",
scwx::util::TimeString(record.first));
}
}
logger_->info(" Level 3");
{
std::shared_lock level3ProductLock {
radarProductManager->p->level3ProductRecordMutex_};
for (auto& recordMap :
radarProductManager->p->level3ProductRecordsMap_)
{
// Product Name
logger_->info(" {}", recordMap.first);
for (auto& record : recordMap.second)
{
logger_->info(" {}",
scwx::util::TimeString(record.first));
}
}
}
}
}
});
}
const std::vector<float>&
RadarProductManager::coordinates(common::RadialSize radialSize) const
{
@ -1030,7 +1082,7 @@ RadarProductManager::Instance(const std::string& radarSite)
bool instanceCreated = false;
{
std::lock_guard<std::mutex> guard(instanceMutex_);
std::unique_lock lock {instanceMutex_};
// Look up instance weak pointer
auto it = instanceMap_.find(radarSite);

View file

@ -34,6 +34,11 @@ public:
static void Cleanup();
/**
* @brief Debug function to dump currently loaded products to the log.
*/
static void DumpRecords();
const std::vector<float>& coordinates(common::RadialSize radialSize) const;
float gate_size() const;
std::shared_ptr<config::RadarSite> radar_site() const;