Skip to content

Commit

Permalink
Merge pull request #34802 from Dr15Jones/XrdStatistics
Browse files Browse the repository at this point in the history
Create abstract XrdStatistics class
  • Loading branch information
cmsbuild committed Aug 6, 2021
2 parents 0457bc7 + 5b76a72 commit 0aa0e6d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
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

0 comments on commit 0aa0e6d

Please sign in to comment.