CMS 3D CMS Logo

Classes | Macros | Functions | Variables
XrdRequestManager.cc File Reference
#include <cassert>
#include <iostream>
#include <algorithm>
#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/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.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);
 
#define XRD_ADAPTOR_CHUNK_THRESHOLD   1000
 
#define XRD_ADAPTOR_LONG_OPEN_DELAY   2 * 60
 
#define XRD_ADAPTOR_OPEN_PROBE_PERCENT   10
 
#define XRD_ADAPTOR_SHORT_OPEN_DELAY   5
 
#define XRD_ADAPTOR_SOURCE_QUALITY_FUDGE   100
 
#define XRD_CL_MAX_CHUNK   512 * 1024
 

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
 

Macro Definition Documentation

#define GET_CLOCK_MONOTONIC (   ts)    clock_gettime(CLOCK_MONOTONIC, &ts);
#define XRD_ADAPTOR_CHUNK_THRESHOLD   1000
#define XRD_ADAPTOR_LONG_OPEN_DELAY   2 * 60
#define XRD_ADAPTOR_OPEN_PROBE_PERCENT   10

Definition at line 31 of file XrdRequestManager.cc.

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

#define XRD_ADAPTOR_SHORT_OPEN_DELAY   5
#define XRD_ADAPTOR_SOURCE_QUALITY_FUDGE   100

Definition at line 33 of file XrdRequestManager.cc.

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

#define XRD_CL_MAX_CHUNK   512 * 1024

Function Documentation

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

Definition at line 834 of file XrdRequestManager.cc.

References IOPosBuffer::data(), IOPosBuffer::offset(), IOPosBuffer::set_data(), IOPosBuffer::set_offset(), IOPosBuffer::set_size(), IOPosBuffer::size(), XRD_ADAPTOR_CHUNK_THRESHOLD, and XRD_CL_MAX_CHUNK.

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

837  {
838  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
839  IOPosBuffer &io = input.back();
840  IOPosBuffer &outio = output.back();
841  if (io.size() > chunksize) {
842  IOSize consumed;
843  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
844  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
845  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
846  consumed = (XRD_CL_MAX_CHUNK - outio.size());
847  outio.set_size(XRD_CL_MAX_CHUNK);
848  } else {
849  consumed = chunksize;
850  outio.set_size(outio.size() + consumed);
851  }
852  } else {
853  consumed = chunksize;
854  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
855  }
856  chunksize -= consumed;
857  IOSize newsize = io.size() - consumed;
858  IOOffset newoffset = io.offset() + consumed;
859  void *newdata = static_cast<char *>(io.data()) + consumed;
860  io.set_offset(newoffset);
861  io.set_data(newdata);
862  io.set_size(newsize);
863  } else if (io.size() == 0) {
864  input.pop_back();
865  } else {
866  output.push_back(io);
867  chunksize -= io.size();
868  input.pop_back();
869  }
870  }
871 }
#define XRD_CL_MAX_CHUNK
static std::string const input
Definition: EdmProvDump.cc:44
#define XRD_ADAPTOR_CHUNK_THRESHOLD
void set_data(void *new_buffer)
Definition: IOPosBuffer.h:74
void set_size(IOSize new_size)
Definition: IOPosBuffer.h:79
void set_offset(IOOffset new_offset)
Definition: IOPosBuffer.h:69
IOOffset offset(void) const
Definition: IOPosBuffer.h:54
void * data(void) const
Definition: IOPosBuffer.h:59
IOSize size(void) const
Definition: IOPosBuffer.h:64
int64_t IOOffset
Definition: IOTypes.h:19
size_t IOSize
Definition: IOTypes.h:14
static void consumeChunkFront ( size_t &  front,
std::vector< IOPosBuffer > &  input,
std::vector< IOPosBuffer > &  output,
IOSize  chunksize 
)
static

Definition at line 795 of file XrdRequestManager.cc.

References IOPosBuffer::data(), IOPosBuffer::offset(), IOPosBuffer::set_data(), IOPosBuffer::set_offset(), IOPosBuffer::set_size(), IOPosBuffer::size(), XRD_ADAPTOR_CHUNK_THRESHOLD, and XRD_CL_MAX_CHUNK.

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

798  {
799  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
800  IOPosBuffer &io = input[front];
801  IOPosBuffer &outio = output.back();
802  if (io.size() > chunksize) {
803  IOSize consumed;
804  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
805  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
806  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
807  consumed = (XRD_CL_MAX_CHUNK - outio.size());
808  outio.set_size(XRD_CL_MAX_CHUNK);
809  } else {
810  consumed = chunksize;
811  outio.set_size(outio.size() + consumed);
812  }
813  } else {
814  consumed = chunksize;
815  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
816  }
817  chunksize -= consumed;
818  IOSize newsize = io.size() - consumed;
819  IOOffset newoffset = io.offset() + consumed;
820  void *newdata = static_cast<char *>(io.data()) + consumed;
821  io.set_offset(newoffset);
822  io.set_data(newdata);
823  io.set_size(newsize);
824  } else if (io.size() == 0) {
825  front++;
826  } else {
827  output.push_back(io);
828  chunksize -= io.size();
829  front++;
830  }
831  }
832 }
#define XRD_CL_MAX_CHUNK
static std::string const input
Definition: EdmProvDump.cc:44
#define XRD_ADAPTOR_CHUNK_THRESHOLD
void set_data(void *new_buffer)
Definition: IOPosBuffer.h:74
void set_size(IOSize new_size)
Definition: IOPosBuffer.h:79
void set_offset(IOOffset new_offset)
Definition: IOPosBuffer.h:69
IOOffset offset(void) const
Definition: IOPosBuffer.h:54
void * data(void) const
Definition: IOPosBuffer.h:59
IOSize size(void) const
Definition: IOPosBuffer.h:64
int64_t IOOffset
Definition: IOTypes.h:19
size_t IOSize
Definition: IOTypes.h:14
static void SendMonitoringInfo ( XrdCl::File &  file)
static

Definition at line 83 of file XrdRequestManager.cc.

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

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

83  {
84  // Do not send this to a dCache data server as they return an error.
85  // In some versions of dCache, sending the monitoring information causes
86  // the server to close the connection - resulting in failures.
87  if (Source::isDCachePool(file)) {
88  return;
89  }
90 
91  // Send the monitoring info, if available.
93  std::string lastUrl;
94  file.GetProperty("LastURL", lastUrl);
95  if (jobId && !lastUrl.empty()) {
96  XrdCl::URL url(lastUrl);
97  XrdCl::FileSystem fs(url);
98  if (!(fs.SendInfo(jobId, &nullHandler, 30).IsOK())) {
99  edm::LogWarning("XrdAdaptorInternal")
100  << "Failed to send the monitoring information, monitoring ID is " << jobId << ".";
101  }
102  edm::LogInfo("XrdAdaptorInternal") << "Set monitoring ID to " << jobId << ".";
103  }
104 }
SendMonitoringInfoHandler nullHandler
long long timeDiffMS ( const timespec &  a,
const timespec &  b 
)

Definition at line 57 of file XrdRequestManager.cc.

References diffTreeTool::diff.

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

57  {
58  long long diff = (a.tv_sec - b.tv_sec) * 1000;
59  diff += (a.tv_nsec - b.tv_nsec) / 1e6;
60  return diff;
61 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
static IOSize validateList ( const std::vector< IOPosBuffer req)
static

Definition at line 873 of file XrdRequestManager.cc.

References pileupDistInMC::total, and XRD_CL_MAX_CHUNK.

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

873  {
874  IOSize total = 0;
875  off_t last_offset = -1;
876  for (const auto &it : req) {
877  total += it.size();
878  assert(it.offset() > last_offset);
879  last_offset = it.offset();
880  assert(it.size() <= XRD_CL_MAX_CHUNK);
881  assert(it.offset() < 0x1ffffffffff);
882  }
883  assert(req.size() <= 1024);
884  return total;
885 }
#define XRD_CL_MAX_CHUNK
size_t IOSize
Definition: IOTypes.h:14

Variable Documentation

Definition at line 81 of file XrdRequestManager.cc.