Skip to content

Commit

Permalink
Pass InputType to StatisticsSenderService
Browse files Browse the repository at this point in the history
Now broadcasts how the file is used.
  • Loading branch information
Dr15Jones committed Oct 18, 2021
1 parent 7786d20 commit 56bde9a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion IOPool/Input/src/RootInputFileSequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ namespace edm {
input ? std::make_unique<InputSource::FileOpenSentry>(*input, lfn_, false) : nullptr);
edm::Service<edm::storage::StatisticsSenderService> service;
if (service.isAvailable()) {
service->openingFile(lfn(), -1);
service->openingFile(lfn(), inputType, -1);
}
for (std::vector<std::string>::const_iterator it = fNames.begin(); it != fNames.end(); ++it) {
try {
Expand Down
15 changes: 13 additions & 2 deletions Utilities/StorageFactory/interface/StatisticsSenderService.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <atomic>
#include <mutex>
#include <tbb/concurrent_unordered_map.h>
#include "FWCore/Utilities/interface/InputType.h"

namespace edm {

Expand All @@ -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:
Expand All @@ -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<ssize_t> m_size;
size_t m_id; //from m_counter
std::atomic<int> m_openCount;
Expand Down
31 changes: 27 additions & 4 deletions Utilities/StorageFactory/src/StatisticsSenderService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 56bde9a

Please sign in to comment.