CMS 3D CMS Logo

Classes | Macros | Functions
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/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);
 
#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)
 

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 33 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 35 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 853 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().

856  {
857  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
858  IOPosBuffer &io = input.back();
859  IOPosBuffer &outio = output.back();
860  if (io.size() > chunksize) {
861  IOSize consumed;
862  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
863  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
864  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
865  consumed = (XRD_CL_MAX_CHUNK - outio.size());
866  outio.set_size(XRD_CL_MAX_CHUNK);
867  } else {
868  consumed = chunksize;
869  outio.set_size(outio.size() + consumed);
870  }
871  } else {
872  consumed = chunksize;
873  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
874  }
875  chunksize -= consumed;
876  IOSize newsize = io.size() - consumed;
877  IOOffset newoffset = io.offset() + consumed;
878  void *newdata = static_cast<char *>(io.data()) + consumed;
879  io.set_offset(newoffset);
880  io.set_data(newdata);
881  io.set_size(newsize);
882  } else if (io.size() == 0) {
883  input.pop_back();
884  } else {
885  output.push_back(io);
886  chunksize -= io.size();
887  input.pop_back();
888  }
889  }
890 }
#define XRD_CL_MAX_CHUNK
static std::string const input
Definition: EdmProvDump.cc:48
#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 814 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().

817  {
818  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
819  IOPosBuffer &io = input[front];
820  IOPosBuffer &outio = output.back();
821  if (io.size() > chunksize) {
822  IOSize consumed;
823  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
824  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
825  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
826  consumed = (XRD_CL_MAX_CHUNK - outio.size());
827  outio.set_size(XRD_CL_MAX_CHUNK);
828  } else {
829  consumed = chunksize;
830  outio.set_size(outio.size() + consumed);
831  }
832  } else {
833  consumed = chunksize;
834  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
835  }
836  chunksize -= consumed;
837  IOSize newsize = io.size() - consumed;
838  IOOffset newoffset = io.offset() + consumed;
839  void *newdata = static_cast<char *>(io.data()) + consumed;
840  io.set_offset(newoffset);
841  io.set_data(newdata);
842  io.set_size(newsize);
843  } else if (io.size() == 0) {
844  front++;
845  } else {
846  output.push_back(io);
847  chunksize -= io.size();
848  front++;
849  }
850  }
851 }
#define XRD_CL_MAX_CHUNK
static std::string const input
Definition: EdmProvDump.cc:48
#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 95 of file XrdRequestManager.cc.

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

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

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

Definition at line 59 of file XrdRequestManager.cc.

References diffTreeTool::diff.

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

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

Definition at line 892 of file XrdRequestManager.cc.

References pileupDistInMC::total, and XRD_CL_MAX_CHUNK.

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

892  {
893  IOSize total = 0;
894  off_t last_offset = -1;
895  for (const auto &it : req) {
896  total += it.size();
897  assert(it.offset() > last_offset);
898  last_offset = it.offset();
899  assert(it.size() <= XRD_CL_MAX_CHUNK);
900  assert(it.offset() < 0x1ffffffffff);
901  }
902  assert(req.size() <= 1024);
903  return total;
904 }
#define XRD_CL_MAX_CHUNK
size_t IOSize
Definition: IOTypes.h:14