From 56bde9acb7bc10ed63ccda5b8dc585e2b9a4dcdb Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 18 Oct 2021 13:19:14 -0500 Subject: [PATCH] Pass InputType to StatisticsSenderService Now broadcasts how the file is used. --- IOPool/Input/src/RootInputFileSequence.cc | 2 +- .../interface/StatisticsSenderService.h | 15 +++++++-- .../src/StatisticsSenderService.cc | 31 ++++++++++++++++--- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/IOPool/Input/src/RootInputFileSequence.cc b/IOPool/Input/src/RootInputFileSequence.cc index 152e8cf0c695d..553644e16b9e9 100644 --- a/IOPool/Input/src/RootInputFileSequence.cc +++ b/IOPool/Input/src/RootInputFileSequence.cc @@ -247,7 +247,7 @@ namespace edm { input ? std::make_unique(*input, lfn_, false) : nullptr); edm::Service service; if (service.isAvailable()) { - service->openingFile(lfn(), -1); + service->openingFile(lfn(), inputType, -1); } for (std::vector::const_iterator it = fNames.begin(); it != fNames.end(); ++it) { try { diff --git a/Utilities/StorageFactory/interface/StatisticsSenderService.h b/Utilities/StorageFactory/interface/StatisticsSenderService.h index 61bfd55517136..25d715e035abb 100644 --- a/Utilities/StorageFactory/interface/StatisticsSenderService.h +++ b/Utilities/StorageFactory/interface/StatisticsSenderService.h @@ -7,6 +7,7 @@ #include #include #include +#include "FWCore/Utilities/interface/InputType.h" namespace edm { @@ -24,7 +25,7 @@ namespace edm { static const char* getJobID(); static bool getX509Subject(std::string&); - void openingFile(std::string const& lfn, size_t size = -1); + void openingFile(std::string const& lfn, edm::InputType type, size_t size = -1); void closedFile(std::string const& lfn, bool usedFallback); private: @@ -50,10 +51,20 @@ namespace edm { }; struct FileInfo { - explicit FileInfo(std::string const& iLFN); + explicit FileInfo(std::string const& iLFN, edm::InputType); + + FileInfo(FileInfo&& iInfo) + : m_filelfn(std::move(iInfo.m_filelfn)), + m_serverhost(std::move(iInfo.m_serverhost)), + m_serverdomain(std::move(iInfo.m_serverdomain)), + m_type(iInfo.m_type), + m_size(iInfo.m_size.load()), + m_id(iInfo.m_id), + m_openCount(iInfo.m_openCount.load()) {} std::string m_filelfn; std::string m_serverhost; std::string m_serverdomain; + edm::InputType m_type; std::atomic m_size; size_t m_id; //from m_counter std::atomic m_openCount; diff --git a/Utilities/StorageFactory/src/StatisticsSenderService.cc b/Utilities/StorageFactory/src/StatisticsSenderService.cc index 32fb96fb70068..ea0a917eb0234 100644 --- a/Utilities/StorageFactory/src/StatisticsSenderService.cc +++ b/Utilities/StorageFactory/src/StatisticsSenderService.cc @@ -156,8 +156,14 @@ void StatisticsSenderService::FileStatistics::update() { m_read_vector_bytes = read_vector_bytes; m_start_time = time(nullptr); } -StatisticsSenderService::FileInfo::FileInfo(std::string const &iLFN) - : m_filelfn(iLFN), m_serverhost("unknown"), m_serverdomain("unknown"), m_size(-1), m_id(0), m_openCount(1) {} +StatisticsSenderService::FileInfo::FileInfo(std::string const &iLFN, edm::InputType iType) + : m_filelfn(iLFN), + m_serverhost("unknown"), + m_serverdomain("unknown"), + m_type(iType), + m_size(-1), + m_id(0), + m_openCount(1) {} StatisticsSenderService::StatisticsSenderService(edm::ParameterSet const &iPSet, edm::ActivityRegistry &ar) : m_clienthost("unknown"), @@ -237,9 +243,9 @@ void StatisticsSenderService::setCurrentServer(const std::string &url, const std } } -void StatisticsSenderService::openingFile(std::string const &lfn, size_t size) { +void StatisticsSenderService::openingFile(std::string const &lfn, edm::InputType type, size_t size) { m_urlToLfn.emplace(lfn, lfn); - auto attempt = m_lfnToFileInfo.emplace(lfn, lfn); + auto attempt = m_lfnToFileInfo.emplace(lfn, FileInfo{lfn, type}); if (attempt.second) { attempt.first->second.m_size = size; attempt.first->second.m_id = m_counter++; @@ -377,6 +383,23 @@ void StatisticsSenderService::fillUDP(const std::string &siteName, } if (usedFallback) { os << "\"fallback\": true, "; + } else { + os << "\"fallback\": false, "; + } + os << "\"type\": "; + switch (fileinfo.m_type) { + case edm::InputType::Primary: { + os << "\"primary\", "; + break; + } + case edm::InputType::SecondaryFile: { + os << "\"secondary\", "; + break; + } + case edm::InputType::SecondarySource: { + os << "\"embedded\", "; + break; + } } auto serverhost = fileinfo.m_serverhost; auto serverdomain = fileinfo.m_serverdomain;