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/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 56 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_CHUNK_THRESHOLD

#define XRD_ADAPTOR_CHUNK_THRESHOLD   1000

Definition at line 40 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_LONG_OPEN_DELAY

#define XRD_ADAPTOR_LONG_OPEN_DELAY   2 * 60

Definition at line 36 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_OPEN_PROBE_PERCENT

#define XRD_ADAPTOR_OPEN_PROBE_PERCENT   10

Definition at line 35 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_SHORT_OPEN_DELAY

#define XRD_ADAPTOR_SHORT_OPEN_DELAY   5

Definition at line 27 of file XrdRequestManager.cc.

◆ XRD_ADAPTOR_SOURCE_QUALITY_FUDGE

#define XRD_ADAPTOR_SOURCE_QUALITY_FUDGE   100

Definition at line 37 of file XrdRequestManager.cc.

◆ XRD_CL_MAX_CHUNK

#define XRD_CL_MAX_CHUNK   512 * 1024

Definition at line 25 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 843 of file XrdRequestManager.cc.

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

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 804 of file XrdRequestManager.cc.

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

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 92 of file XrdRequestManager.cc.

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

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 61 of file XrdRequestManager.cc.

61  {
62  long long diff = (a.tv_sec - b.tv_sec) * 1000;
63  diff += (a.tv_nsec - b.tv_nsec) / 1e6;
64  return diff;
65 }

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 882 of file XrdRequestManager.cc.

882  {
883  IOSize total = 0;
884  off_t last_offset = -1;
885  for (const auto &it : req) {
886  total += it.size();
887  assert(it.offset() > last_offset);
888  last_offset = it.offset();
889  assert(it.size() <= XRD_CL_MAX_CHUNK);
890  assert(it.offset() < 0x1ffffffffff);
891  }
892  assert(req.size() <= 1024);
893  return total;
894 }

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

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

Variable Documentation

◆ nullHandler

Definition at line 90 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:72
XRD_ADAPTOR_CHUNK_THRESHOLD
#define XRD_ADAPTOR_CHUNK_THRESHOLD
Definition: XrdRequestManager.cc:40
IOPosBuffer::set_data
void set_data(void *new_buffer)
Definition: IOPosBuffer.h:51
cms::cuda::assert
assert(be >=bs)
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
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:25
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:90
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