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/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)
 

Variables

SendMonitoringInfoHandler nullHandler
 

Macro Definition Documentation

◆ GET_CLOCK_MONOTONIC

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

Definition at line 54 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_CHUNK_THRESHOLD

#define XRD_ADAPTOR_CHUNK_THRESHOLD   1000

Definition at line 38 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_LONG_OPEN_DELAY

#define XRD_ADAPTOR_LONG_OPEN_DELAY   2 * 60

Definition at line 34 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_OPEN_PROBE_PERCENT

#define XRD_ADAPTOR_OPEN_PROBE_PERCENT   10

Definition at line 33 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_SHORT_OPEN_DELAY

#define XRD_ADAPTOR_SHORT_OPEN_DELAY   5

Definition at line 25 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_SOURCE_QUALITY_FUDGE

#define XRD_ADAPTOR_SOURCE_QUALITY_FUDGE   100

Definition at line 35 of file XrdRequestManager.cc.

◆ XRD_CL_MAX_CHUNK

#define XRD_CL_MAX_CHUNK   512 * 1024

Definition at line 23 of file XrdRequestManager.cc.

Function Documentation

◆ consumeChunkBack()

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

Definition at line 836 of file XrdRequestManager.cc.

839  {
840  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
841  IOPosBuffer &io = input.back();
842  IOPosBuffer &outio = output.back();
843  if (io.size() > chunksize) {
844  IOSize consumed;
845  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
846  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
847  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
848  consumed = (XRD_CL_MAX_CHUNK - outio.size());
849  outio.set_size(XRD_CL_MAX_CHUNK);
850  } else {
851  consumed = chunksize;
852  outio.set_size(outio.size() + consumed);
853  }
854  } else {
855  consumed = chunksize;
856  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
857  }
858  chunksize -= consumed;
859  IOSize newsize = io.size() - consumed;
860  IOOffset newoffset = io.offset() + consumed;
861  void *newdata = static_cast<char *>(io.data()) + consumed;
862  io.set_offset(newoffset);
863  io.set_data(newdata);
864  io.set_size(newsize);
865  } else if (io.size() == 0) {
866  input.pop_back();
867  } else {
868  output.push_back(io);
869  chunksize -= io.size();
870  input.pop_back();
871  }
872  }
873 }

References IOPosBuffer::data(), input, IOPosBuffer::offset(), convertSQLitetoXML_cfg::output, 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().

◆ consumeChunkFront()

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

Definition at line 797 of file XrdRequestManager.cc.

800  {
801  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD)) {
802  IOPosBuffer &io = input[front];
803  IOPosBuffer &outio = output.back();
804  if (io.size() > chunksize) {
805  IOSize consumed;
806  if (!output.empty() && (outio.size() < XRD_CL_MAX_CHUNK) &&
807  (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset())) {
808  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK) {
809  consumed = (XRD_CL_MAX_CHUNK - outio.size());
810  outio.set_size(XRD_CL_MAX_CHUNK);
811  } else {
812  consumed = chunksize;
813  outio.set_size(outio.size() + consumed);
814  }
815  } else {
816  consumed = chunksize;
817  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
818  }
819  chunksize -= consumed;
820  IOSize newsize = io.size() - consumed;
821  IOOffset newoffset = io.offset() + consumed;
822  void *newdata = static_cast<char *>(io.data()) + consumed;
823  io.set_offset(newoffset);
824  io.set_data(newdata);
825  io.set_size(newsize);
826  } else if (io.size() == 0) {
827  front++;
828  } else {
829  output.push_back(io);
830  chunksize -= io.size();
831  front++;
832  }
833  }
834 }

References IOPosBuffer::data(), input, IOPosBuffer::offset(), convertSQLitetoXML_cfg::output, 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().

◆ SendMonitoringInfo()

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

Definition at line 85 of file XrdRequestManager.cc.

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

References FrontierConditions_GlobalTag_cff::file, 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().

◆ timeDiffMS()

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

Definition at line 59 of file XrdRequestManager.cc.

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 }

References a, b, and change_name::diff.

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

◆ validateList()

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

Definition at line 875 of file XrdRequestManager.cc.

875  {
876  IOSize total = 0;
877  off_t last_offset = -1;
878  for (const auto &it : req) {
879  total += it.size();
880  assert(it.offset() > last_offset);
881  last_offset = it.offset();
882  assert(it.size() <= XRD_CL_MAX_CHUNK);
883  assert(it.offset() < 0x1ffffffffff);
884  }
885  assert(req.size() <= 1024);
886  return total;
887 }

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

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

Variable Documentation

◆ nullHandler

Definition at line 83 of file XrdRequestManager.cc.

Referenced by SendMonitoringInfo().

IOPosBuffer::set_offset
void set_offset(IOOffset new_offset)
Definition: IOPosBuffer.h:48
change_name.diff
diff
Definition: change_name.py:13
relmon_authenticated_wget.url
url
Definition: relmon_authenticated_wget.py:22
input
static const std::string input
Definition: EdmProvDump.cc:48
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
edm::LogInfo
Definition: MessageLogger.h:254
XRD_ADAPTOR_CHUNK_THRESHOLD
#define XRD_ADAPTOR_CHUNK_THRESHOLD
Definition: XrdRequestManager.cc:38
IOPosBuffer::set_data
void set_data(void *new_buffer)
Definition: IOPosBuffer.h:51
cms::cuda::assert
assert(be >=bs)
IOPosBuffer::data
void * data(void) const
Definition: IOPosBuffer.h:42
b
double b
Definition: hdecay.h:118
XRD_CL_MAX_CHUNK
#define XRD_CL_MAX_CHUNK
Definition: XrdRequestManager.cc:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
IOPosBuffer::set_size
void set_size(IOSize new_size)
Definition: IOPosBuffer.h:54
a
double a
Definition: hdecay.h:119
IOOffset
int64_t IOOffset
Definition: IOTypes.h:19
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
nullHandler
SendMonitoringInfoHandler nullHandler
Definition: XrdRequestManager.cc:83
IOPosBuffer::size
IOSize size(void) const
Definition: IOPosBuffer.h:45
edm::storage::StatisticsSenderService::getJobID
static const char * getJobID()
Definition: StatisticsSenderService.cc:145
IOPosBuffer::offset
IOOffset offset(void) const
Definition: IOPosBuffer.h:39
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
IOPosBuffer
Definition: IOPosBuffer.h:7
hcal_runs.URL
URL
Definition: hcal_runs.py:4
IOSize
size_t IOSize
Definition: IOTypes.h:14