Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create abstract XrdStatistics class #34802

Merged
merged 1 commit into from Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion FWCore/Framework/src/defaultCmsRunServices.cc
Expand Up @@ -24,7 +24,7 @@ namespace edm {
"SiteLocalConfigService",
"StatisticsSenderService",
"CondorStatusService",
"XrdAdaptor::XrdStatisticsService"};
"XrdStatisticsService"};

return returnValue;
}
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Services/plugins/CondorStatusUpdater.cc
Expand Up @@ -12,7 +12,7 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/Registry.h"
#include "Utilities/StorageFactory/interface/StorageAccount.h"
#include "Utilities/XrdAdaptor/src/XrdStatistics.h"
#include "Utilities/XrdAdaptor/interface/XrdStatistics.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"

#include <fcntl.h>
Expand Down Expand Up @@ -294,7 +294,7 @@ void CondorStatusService::updateImpl(time_t sinceLastUpdate) {
}

// If Xrootd was used, pull the statistics from there.
edm::Service<XrdAdaptor::XrdStatisticsService> xrdsvc;
edm::Service<xrd_adaptor::XrdStatistics> xrdsvc;
if (xrdsvc.isAvailable()) {
for (auto const &iter : xrdsvc->condorUpdate()) {
std::string site = iter.first;
Expand Down
29 changes: 29 additions & 0 deletions Utilities/XrdAdaptor/interface/XrdStatistics.h
@@ -0,0 +1,29 @@
#ifndef Utilities_XrdAdaptor_XrdStatistics_h
#define Utilities_XrdAdaptor_XrdStatistics_h

#include <vector>
#include <string>
#include <chrono>

namespace xrd_adaptor {

class XrdStatistics {
public:
XrdStatistics() {}
virtual ~XrdStatistics();

struct CondorIOStats {
uint64_t bytesRead{0};
std::chrono::nanoseconds transferTime{0};
};

// Provide an update of per-site transfer statistics to the CondorStatusService.
// Returns a mapping of "site name" to transfer statistics. The "site name" is
// as self-identified by the Xrootd host; may not necessarily match up with the
// "CMS site name".
virtual std::vector<std::pair<std::string, CondorIOStats>> condorUpdate() = 0;
};

} // namespace xrd_adaptor

#endif
5 changes: 4 additions & 1 deletion Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc
Expand Up @@ -180,4 +180,7 @@ class XrdStorageMaker final : public StorageMaker {
};

DEFINE_EDM_PLUGIN(StorageMakerFactory, XrdStorageMaker, "root");
DEFINE_FWK_SERVICE(XrdAdaptor::XrdStatisticsService);
using XrdStatisticsMaker =
edm::serviceregistry::AllArgsMaker<xrd_adaptor::XrdStatistics, XrdAdaptor::XrdStatisticsService>;
using XrdAdaptor::XrdStatisticsService;
DEFINE_FWK_SERVICE_MAKER(XrdStatisticsService, XrdStatisticsMaker);
6 changes: 5 additions & 1 deletion Utilities/XrdAdaptor/src/XrdStatistics.cc
Expand Up @@ -11,6 +11,10 @@

#include <chrono>

namespace xrd_adaptor {
XrdStatistics::~XrdStatistics() {}
} // namespace xrd_adaptor

using namespace XrdAdaptor;

std::atomic<XrdSiteStatisticsInformation *> XrdSiteStatisticsInformation::m_instance;
Expand Down Expand Up @@ -94,7 +98,7 @@ void XrdStatisticsService::fillDescriptions(edm::ConfigurationDescriptions &desc
->setComment(
"True: Add per-site Xrootd statistics to the framework job report.\n"
"False: Collect no site-specific statistics.\n");
descriptions.add("XrdAdaptor::XrdStatisticsService", desc);
descriptions.add("XrdStatisticsService", desc);
}

XrdSiteStatistics::XrdSiteStatistics(std::string const &site)
Expand Down
12 changes: 4 additions & 8 deletions Utilities/XrdAdaptor/src/XrdStatistics.h
Expand Up @@ -2,6 +2,7 @@
#define __XRD_STATISTICS_SERVICE_H_

#include "Utilities/StorageFactory/interface/IOTypes.h"
#include "Utilities/XrdAdaptor/interface/XrdStatistics.h"
#include "FWCore/Utilities/interface/propagate_const.h"

#include <atomic>
Expand Down Expand Up @@ -32,24 +33,19 @@ namespace XrdAdaptor {
* singleton on non-CMSSW-created threads. Services are only available to threads
* created by CMSSW.
*/
class XrdStatisticsService {
class XrdStatisticsService : public xrd_adaptor::XrdStatistics {
public:
XrdStatisticsService(const edm::ParameterSet &iPS, edm::ActivityRegistry &iRegistry);

void postEndJob();

void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

struct CondorIOStats {
uint64_t bytesRead{0};
std::chrono::nanoseconds transferTime{0};
};
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

// Provide an update of per-site transfer statistics to the CondorStatusService.
// Returns a mapping of "site name" to transfer statistics. The "site name" is
// as self-identified by the Xrootd host; may not necessarily match up with the
// "CMS site name".
std::vector<std::pair<std::string, CondorIOStats>> condorUpdate();
std::vector<std::pair<std::string, CondorIOStats>> condorUpdate() final;
};

class XrdSiteStatisticsInformation {
Expand Down