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/XrdClPostMasterInterfaces.hh"
#include "XrdCl/XrdClPostMaster.hh"
#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 941 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().

944  {
945  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
946  IOPosBuffer &io = input.back();
947  IOPosBuffer &outio = output.back();
948  if (io.size() > chunksize) {
949  IOSize consumed;
950  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
951  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
952  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
953  consumed = (XRD_CL_MAX_CHUNK - outio.size());
954  outio.set_size(XRD_CL_MAX_CHUNK);
955  } else {
956  consumed = chunksize;
957  outio.set_size(outio.size() + consumed);
958  }
959  } else {
960  consumed = chunksize;
961  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
962  }
963  chunksize -= consumed;
964  IOSize newsize = io.size() - consumed;
965  IOOffset newoffset = io.offset() + consumed;
966  void *newdata = static_cast<char *>(io.data()) + consumed;
967  io.set_offset(newoffset);
968  io.set_data(newdata);
969  io.set_size(newsize);
970  } else if (io.size() == 0) {
971  input.pop_back();
972  } else {
973  output.push_back(io);
974  chunksize -= io.size();
975  input.pop_back();
976  }
977  }
978 }
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:50
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 902 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().

905  {
906  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
907  IOPosBuffer &io = input[front];
908  IOPosBuffer &outio = output.back();
909  if (io.size() > chunksize) {
910  IOSize consumed;
911  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
912  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
913  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
914  consumed = (XRD_CL_MAX_CHUNK - outio.size());
915  outio.set_size(XRD_CL_MAX_CHUNK);
916  } else {
917  consumed = chunksize;
918  outio.set_size(outio.size() + consumed);
919  }
920  } else {
921  consumed = chunksize;
922  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
923  }
924  chunksize -= consumed;
925  IOSize newsize = io.size() - consumed;
926  IOOffset newoffset = io.offset() + consumed;
927  void *newdata = static_cast<char *>(io.data()) + consumed;
928  io.set_offset(newoffset);
929  io.set_data(newdata);
930  io.set_size(newsize);
931  } else if (io.size() == 0) {
932  front++;
933  } else {
934  output.push_back(io);
935  chunksize -= io.size();
936  front++;
937  }
938  }
939 }
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:50
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 101 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().

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

◆ timeDiffMS()

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

Definition at line 65 of file XrdRequestManager.cc.

References a, b, and change_name::diff.

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

65  {
66  long long diff = (a.tv_sec - b.tv_sec) * 1000;
67  diff += (a.tv_nsec - b.tv_nsec) / 1e6;
68  return diff;
69 }
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 980 of file XrdRequestManager.cc.

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

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

980  {
981  IOSize total = 0;
982  off_t last_offset = -1;
983  for (const auto &it : req) {
984  total += it.size();
985  assert(it.offset() > last_offset);
986  last_offset = it.offset();
987  assert(it.size() <= XRD_CL_MAX_CHUNK);
988  assert(it.offset() < 0x1ffffffffff);
989  }
990  assert(req.size() <= 1024);
991  return total;
992 }
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 38 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 40 of file XrdRequestManager.cc.

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

◆ XRD_CL_MAX_CHUNK

constexpr int XRD_CL_MAX_CHUNK = 512 * 1024
static