CMS 3D CMS Logo

Classes | Macros | Functions | Variables
XrdRequestManager.cc File Reference
#include <algorithm>
#include <cassert>
#include <iostream>
#include <memory>
#include <netdb.h>
#include "XrdCl/XrdClFile.hh"
#include "XrdCl/XrdClDefaultEnv.hh"
#include "XrdCl/XrdClFileSystem.hh"
#include "FWCore/Utilities/interface/CPUTimer.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/Likely.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include "Utilities/StorageFactory/interface/StatisticsSenderService.h"
#include "XrdStatistics.h"
#include "Utilities/XrdAdaptor/src/XrdRequestManager.h"
#include "Utilities/XrdAdaptor/src/XrdHostHandler.hh"

Go to the source code of this file.

Classes

class  SendMonitoringInfoHandler
 

Macros

#define GET_CLOCK_MONOTONIC(ts)   clock_gettime(CLOCK_MONOTONIC, &ts);
 

Functions

static void consumeChunkBack (size_t front, std::vector< IOPosBuffer > &input, std::vector< IOPosBuffer > &output, IOSize chunksize)
 
static void consumeChunkFront (size_t &front, std::vector< IOPosBuffer > &input, std::vector< IOPosBuffer > &output, IOSize chunksize)
 
static void SendMonitoringInfo (XrdCl::File &file)
 
long long timeDiffMS (const timespec &a, const timespec &b)
 
static IOSize validateList (const std::vector< IOPosBuffer > req)
 

Variables

static constexpr int XRD_ADAPTOR_CHUNK_THRESHOLD = 1000
 
static constexpr int XRD_ADAPTOR_LONG_OPEN_DELAY = 2 * 60
 
static constexpr int XRD_ADAPTOR_OPEN_PROBE_PERCENT = 10
 
static constexpr int XRD_ADAPTOR_SHORT_OPEN_DELAY = 5
 
static constexpr int XRD_ADAPTOR_SOURCE_QUALITY_FUDGE = 100
 
static constexpr int XRD_CL_MAX_CHUNK = 512 * 1024
 

Macro Definition Documentation

◆ GET_CLOCK_MONOTONIC

#define GET_CLOCK_MONOTONIC (   ts)    clock_gettime(CLOCK_MONOTONIC, &ts);

Function Documentation

◆ consumeChunkBack()

static void consumeChunkBack ( size_t  front,
std::vector< IOPosBuffer > &  input,
std::vector< IOPosBuffer > &  output,
IOSize  chunksize 
)
static

Definition at line 863 of file XrdRequestManager.cc.

References edm::storage::IOPosBuffer::data(), input, edm::storage::IOPosBuffer::offset(), convertSQLitetoXML_cfg::output, edm::storage::IOPosBuffer::set_data(), edm::storage::IOPosBuffer::set_offset(), edm::storage::IOPosBuffer::set_size(), edm::storage::IOPosBuffer::size(), XRD_ADAPTOR_CHUNK_THRESHOLD, and XRD_CL_MAX_CHUNK.

Referenced by XrdAdaptor::RequestManager::splitClientRequest().

866  {
867  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
868  IOPosBuffer &io = input.back();
869  IOPosBuffer &outio = output.back();
870  if (io.size() > chunksize) {
871  IOSize consumed;
872  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
873  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
874  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
875  consumed = (XRD_CL_MAX_CHUNK - outio.size());
876  outio.set_size(XRD_CL_MAX_CHUNK);
877  } else {
878  consumed = chunksize;
879  outio.set_size(outio.size() + consumed);
880  }
881  } else {
882  consumed = chunksize;
883  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
884  }
885  chunksize -= consumed;
886  IOSize newsize = io.size() - consumed;
887  IOOffset newoffset = io.offset() + consumed;
888  void *newdata = static_cast<char *>(io.data()) + consumed;
889  io.set_offset(newoffset);
890  io.set_data(newdata);
891  io.set_size(newsize);
892  } else if (io.size() == 0) {
893  input.pop_back();
894  } else {
895  output.push_back(io);
896  chunksize -= io.size();
897  input.pop_back();
898  }
899  }
900 }
int64_t IOOffset
Definition: IOTypes.h:20
static constexpr int XRD_CL_MAX_CHUNK
void set_size(IOSize new_size)
Definition: IOPosBuffer.h:56
void set_offset(IOOffset new_offset)
Definition: IOPosBuffer.h:50
IOOffset offset() const
Definition: IOPosBuffer.h:41
static std::string const input
Definition: EdmProvDump.cc:47
size_t IOSize
Definition: IOTypes.h:15
void set_data(void *new_buffer)
Definition: IOPosBuffer.h:53
static constexpr int XRD_ADAPTOR_CHUNK_THRESHOLD

◆ consumeChunkFront()

static void consumeChunkFront ( size_t &  front,
std::vector< IOPosBuffer > &  input,
std::vector< IOPosBuffer > &  output,
IOSize  chunksize 
)
static

Definition at line 824 of file XrdRequestManager.cc.

References edm::storage::IOPosBuffer::data(), input, edm::storage::IOPosBuffer::offset(), convertSQLitetoXML_cfg::output, edm::storage::IOPosBuffer::set_data(), edm::storage::IOPosBuffer::set_offset(), edm::storage::IOPosBuffer::set_size(), edm::storage::IOPosBuffer::size(), XRD_ADAPTOR_CHUNK_THRESHOLD, and XRD_CL_MAX_CHUNK.

Referenced by XrdAdaptor::RequestManager::splitClientRequest().

827  {
828  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
829  IOPosBuffer &io = input[front];
830  IOPosBuffer &outio = output.back();
831  if (io.size() > chunksize) {
832  IOSize consumed;
833  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
834  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
835  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
836  consumed = (XRD_CL_MAX_CHUNK - outio.size());
837  outio.set_size(XRD_CL_MAX_CHUNK);
838  } else {
839  consumed = chunksize;
840  outio.set_size(outio.size() + consumed);
841  }
842  } else {
843  consumed = chunksize;
844  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
845  }
846  chunksize -= consumed;
847  IOSize newsize = io.size() - consumed;
848  IOOffset newoffset = io.offset() + consumed;
849  void *newdata = static_cast<char *>(io.data()) + consumed;
850  io.set_offset(newoffset);
851  io.set_data(newdata);
852  io.set_size(newsize);
853  } else if (io.size() == 0) {
854  front++;
855  } else {
856  output.push_back(io);
857  chunksize -= io.size();
858  front++;
859  }
860  }
861 }
int64_t IOOffset
Definition: IOTypes.h:20
static constexpr int XRD_CL_MAX_CHUNK
void set_size(IOSize new_size)
Definition: IOPosBuffer.h:56
void set_offset(IOOffset new_offset)
Definition: IOPosBuffer.h:50
IOOffset offset() const
Definition: IOPosBuffer.h:41
static std::string const input
Definition: EdmProvDump.cc:47
size_t IOSize
Definition: IOTypes.h:15
void set_data(void *new_buffer)
Definition: IOPosBuffer.h:53
static constexpr int XRD_ADAPTOR_CHUNK_THRESHOLD

◆ SendMonitoringInfo()

static void SendMonitoringInfo ( XrdCl::File &  file)
static

Definition at line 98 of file XrdRequestManager.cc.

References geometryDiff::file, edm::storage::StatisticsSenderService::getJobID(), XrdAdaptor::Source::isDCachePool(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by XrdAdaptor::RequestManager::OpenHandler::HandleResponseWithHosts(), and XrdAdaptor::RequestManager::initialize().

98  {
99  // Do not send this to a dCache data server as they return an error.
100  // In some versions of dCache, sending the monitoring information causes
101  // the server to close the connection - resulting in failures.
102  if (Source::isDCachePool(file)) {
103  return;
104  }
105 
106  // Send the monitoring info, if available.
108  std::string lastUrl;
109  file.GetProperty("LastURL", lastUrl);
110  if (jobId && !lastUrl.empty()) {
111  auto sm_handler = new SendMonitoringInfoHandler(lastUrl);
112  if (!(sm_handler->fs().SendInfo(jobId, sm_handler, 30).IsOK())) {
113  edm::LogWarning("XrdAdaptorInternal")
114  << "Failed to send the monitoring information, monitoring ID is " << jobId << ".";
115  delete sm_handler;
116  }
117  edm::LogInfo("XrdAdaptorInternal") << "Set monitoring ID to " << jobId << ".";
118  }
119 }
Log< level::Info, false > LogInfo
Log< level::Warning, false > LogWarning

◆ timeDiffMS()

long long timeDiffMS ( const timespec &  a,
const timespec &  b 
)

Definition at line 62 of file XrdRequestManager.cc.

References a, b, and change_name::diff.

Referenced by XrdAdaptor::RequestManager::checkSources(), and XrdAdaptor::RequestManager::checkSourcesImpl().

62  {
63  long long diff = (a.tv_sec - b.tv_sec) * 1000;
64  diff += (a.tv_nsec - b.tv_nsec) / 1e6;
65  return diff;
66 }
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119

◆ validateList()

static IOSize validateList ( const std::vector< IOPosBuffer req)
static

Definition at line 902 of file XrdRequestManager.cc.

References cms::cuda::assert(), dqmMemoryStats::total, and XRD_CL_MAX_CHUNK.

Referenced by XrdAdaptor::RequestManager::splitClientRequest().

902  {
903  IOSize total = 0;
904  off_t last_offset = -1;
905  for (const auto &it : req) {
906  total += it.size();
907  assert(it.offset() > last_offset);
908  last_offset = it.offset();
909  assert(it.size() <= XRD_CL_MAX_CHUNK);
910  assert(it.offset() < 0x1ffffffffff);
911  }
912  assert(req.size() <= 1024);
913  return total;
914 }
static constexpr int XRD_CL_MAX_CHUNK
assert(be >=bs)
size_t IOSize
Definition: IOTypes.h:15

Variable Documentation

◆ XRD_ADAPTOR_CHUNK_THRESHOLD

constexpr int XRD_ADAPTOR_CHUNK_THRESHOLD = 1000
static

◆ XRD_ADAPTOR_LONG_OPEN_DELAY

constexpr int XRD_ADAPTOR_LONG_OPEN_DELAY = 2 * 60
static

◆ XRD_ADAPTOR_OPEN_PROBE_PERCENT

constexpr int XRD_ADAPTOR_OPEN_PROBE_PERCENT = 10
static

Definition at line 35 of file XrdRequestManager.cc.

Referenced by XrdAdaptor::RequestManager::checkSourcesImpl().

◆ XRD_ADAPTOR_SHORT_OPEN_DELAY

constexpr int XRD_ADAPTOR_SHORT_OPEN_DELAY = 5
static

◆ XRD_ADAPTOR_SOURCE_QUALITY_FUDGE

constexpr int XRD_ADAPTOR_SOURCE_QUALITY_FUDGE = 100
static

Definition at line 37 of file XrdRequestManager.cc.

Referenced by XrdAdaptor::RequestManager::checkSourcesImpl().

◆ XRD_CL_MAX_CHUNK

constexpr int XRD_CL_MAX_CHUNK = 512 * 1024
static