CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

SendMonitoringInfoHandler nullHandler
 
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

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

Function Documentation

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

Definition at line 844 of file XrdRequestManager.cc.

References edm::storage::IOPosBuffer::data(), edm::storage::IOPosBuffer::offset(), 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().

847  {
848  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
849  IOPosBuffer &io = input.back();
850  IOPosBuffer &outio = output.back();
851  if (io.size() > chunksize) {
852  IOSize consumed;
853  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
854  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
855  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
856  consumed = (XRD_CL_MAX_CHUNK - outio.size());
857  outio.set_size(XRD_CL_MAX_CHUNK);
858  } else {
859  consumed = chunksize;
860  outio.set_size(outio.size() + consumed);
861  }
862  } else {
863  consumed = chunksize;
864  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
865  }
866  chunksize -= consumed;
867  IOSize newsize = io.size() - consumed;
868  IOOffset newoffset = io.offset() + consumed;
869  void *newdata = static_cast<char *>(io.data()) + consumed;
870  io.set_offset(newoffset);
871  io.set_data(newdata);
872  io.set_size(newsize);
873  } else if (io.size() == 0) {
874  input.pop_back();
875  } else {
876  output.push_back(io);
877  chunksize -= io.size();
878  input.pop_back();
879  }
880  }
881 }
int64_t IOOffset
Definition: IOTypes.h:20
void * data() const
Definition: IOPosBuffer.h:44
static constexpr int XRD_CL_MAX_CHUNK
IOSize size() const
Definition: IOPosBuffer.h:47
void set_size(IOSize new_size)
Definition: IOPosBuffer.h:56
void set_offset(IOOffset new_offset)
Definition: IOPosBuffer.h:50
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
IOOffset offset() const
Definition: IOPosBuffer.h:41
static void consumeChunkFront ( size_t &  front,
std::vector< IOPosBuffer > &  input,
std::vector< IOPosBuffer > &  output,
IOSize  chunksize 
)
static

Definition at line 805 of file XrdRequestManager.cc.

References edm::storage::IOPosBuffer::data(), edm::storage::IOPosBuffer::offset(), 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().

808  {
809  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
810  IOPosBuffer &io = input[front];
811  IOPosBuffer &outio = output.back();
812  if (io.size() > chunksize) {
813  IOSize consumed;
814  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
815  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
816  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
817  consumed = (XRD_CL_MAX_CHUNK - outio.size());
818  outio.set_size(XRD_CL_MAX_CHUNK);
819  } else {
820  consumed = chunksize;
821  outio.set_size(outio.size() + consumed);
822  }
823  } else {
824  consumed = chunksize;
825  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
826  }
827  chunksize -= consumed;
828  IOSize newsize = io.size() - consumed;
829  IOOffset newoffset = io.offset() + consumed;
830  void *newdata = static_cast<char *>(io.data()) + consumed;
831  io.set_offset(newoffset);
832  io.set_data(newdata);
833  io.set_size(newsize);
834  } else if (io.size() == 0) {
835  front++;
836  } else {
837  output.push_back(io);
838  chunksize -= io.size();
839  front++;
840  }
841  }
842 }
int64_t IOOffset
Definition: IOTypes.h:20
void * data() const
Definition: IOPosBuffer.h:44
static constexpr int XRD_CL_MAX_CHUNK
IOSize size() const
Definition: IOPosBuffer.h:47
void set_size(IOSize new_size)
Definition: IOPosBuffer.h:56
void set_offset(IOOffset new_offset)
Definition: IOPosBuffer.h:50
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
IOOffset offset() const
Definition: IOPosBuffer.h:41
static void SendMonitoringInfo ( XrdCl::File &  file)
static

Definition at line 93 of file XrdRequestManager.cc.

References edm::storage::StatisticsSenderService::getJobID(), XrdAdaptor::Source::isDCachePool(), nullHandler, AlCaHLTBitMon_QueryRunRegistry::string, hcal_runs::URL, and relmon_authenticated_wget::url.

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

93  {
94  // Do not send this to a dCache data server as they return an error.
95  // In some versions of dCache, sending the monitoring information causes
96  // the server to close the connection - resulting in failures.
97  if (Source::isDCachePool(file)) {
98  return;
99  }
100 
101  // Send the monitoring info, if available.
103  std::string lastUrl;
104  file.GetProperty("LastURL", lastUrl);
105  if (jobId && !lastUrl.empty()) {
106  XrdCl::URL url(lastUrl);
107  XrdCl::FileSystem fs(url);
108  if (!(fs.SendInfo(jobId, &nullHandler, 30).IsOK())) {
109  edm::LogWarning("XrdAdaptorInternal")
110  << "Failed to send the monitoring information, monitoring ID is " << jobId << ".";
111  }
112  edm::LogInfo("XrdAdaptorInternal") << "Set monitoring ID to " << jobId << ".";
113  }
114 }
SendMonitoringInfoHandler nullHandler
string URL
Definition: hcal_runs.py:4
Log< level::Info, false > LogInfo
Log< level::Warning, false > LogWarning
long long timeDiffMS ( const timespec &  a,
const timespec &  b 
)

Definition at line 62 of file XrdRequestManager.cc.

References 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
static IOSize validateList ( const std::vector< IOPosBuffer req)
static

Definition at line 883 of file XrdRequestManager.cc.

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

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

883  {
884  IOSize total = 0;
885  off_t last_offset = -1;
886  for (const auto &it : req) {
887  total += it.size();
888  assert(it.offset() > last_offset);
889  last_offset = it.offset();
890  assert(it.size() <= XRD_CL_MAX_CHUNK);
891  assert(it.offset() < 0x1ffffffffff);
892  }
893  assert(req.size() <= 1024);
894  return total;
895 }
static constexpr int XRD_CL_MAX_CHUNK
assert(be >=bs)
size_t IOSize
Definition: IOTypes.h:15

Variable Documentation

Definition at line 91 of file XrdRequestManager.cc.

Referenced by SendMonitoringInfo().

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

Definition at line 35 of file XrdRequestManager.cc.

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

constexpr int XRD_ADAPTOR_SHORT_OPEN_DELAY = 5
static
constexpr int XRD_ADAPTOR_SOURCE_QUALITY_FUDGE = 100
static

Definition at line 37 of file XrdRequestManager.cc.

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

constexpr int XRD_CL_MAX_CHUNK = 512 * 1024
static