CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Macros | Functions | Variables
XrdRequestManager.cc File Reference
#include <assert.h>
#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 937 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().

938 {
939  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD))
940  {
941  IOPosBuffer &io = input.back();
942  IOPosBuffer &outio = output.back();
943  if (io.size() > chunksize)
944  {
945  IOSize consumed;
946  if (output.size() && (outio.size() < XRD_CL_MAX_CHUNK) && (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset()))
947  {
948  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK)
949  {
950  consumed = (XRD_CL_MAX_CHUNK - outio.size());
951  outio.set_size(XRD_CL_MAX_CHUNK);
952  }
953  else
954  {
955  consumed = chunksize;
956  outio.set_size(outio.size() + consumed);
957  }
958  }
959  else
960  {
961  consumed = chunksize;
962  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
963  }
964  chunksize -= consumed;
965  IOSize newsize = io.size() - consumed;
966  IOOffset newoffset = io.offset() + consumed;
967  void* newdata = static_cast<char*>(io.data()) + consumed;
968  io.set_offset(newoffset);
969  io.set_data(newdata);
970  io.set_size(newsize);
971  }
972  else if (io.size() == 0)
973  {
974  input.pop_back();
975  }
976  else
977  {
978  output.push_back(io);
979  chunksize -= io.size();
980  input.pop_back();
981  }
982  }
983 }
#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 888 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().

889 {
890  while ((chunksize > 0) && (front < input.size()) && (output.size() <= XRD_ADAPTOR_CHUNK_THRESHOLD))
891  {
892  IOPosBuffer &io = input[front];
893  IOPosBuffer &outio = output.back();
894  if (io.size() > chunksize)
895  {
896  IOSize consumed;
897  if (output.size() && (outio.size() < XRD_CL_MAX_CHUNK) && (outio.offset() + static_cast<IOOffset>(outio.size()) == io.offset()))
898  {
899  if (outio.size() + chunksize > XRD_CL_MAX_CHUNK)
900  {
901  consumed = (XRD_CL_MAX_CHUNK - outio.size());
902  outio.set_size(XRD_CL_MAX_CHUNK);
903  }
904  else
905  {
906  consumed = chunksize;
907  outio.set_size(outio.size() + consumed);
908  }
909  }
910  else
911  {
912  consumed = chunksize;
913  output.emplace_back(IOPosBuffer(io.offset(), io.data(), chunksize));
914  }
915  chunksize -= consumed;
916  IOSize newsize = io.size() - consumed;
917  IOOffset newoffset = io.offset() + consumed;
918  void* newdata = static_cast<char*>(io.data()) + consumed;
919  io.set_offset(newoffset);
920  io.set_data(newdata);
921  io.set_size(newsize);
922  }
923  else if (io.size() == 0)
924  {
925  front++;
926  }
927  else
928  {
929  output.push_back(io);
930  chunksize -= io.size();
931  front++;
932  }
933  }
934 }
#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 91 of file XrdRequestManager.cc.

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

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

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)) {return;}
97 
98  // Send the monitoring info, if available.
100  std::string lastUrl;
101  file.GetProperty("LastURL", lastUrl);
102  if (jobId && lastUrl.size())
103  {
104  XrdCl::URL url(lastUrl);
105  XrdCl::FileSystem fs(url);
106  if (!(fs.SendInfo(jobId, &nullHandler, 30).IsOK()))
107  {
108  edm::LogWarning("XrdAdaptorInternal") << "Failed to send the monitoring information, monitoring ID is " << jobId << ".";
109  }
110  edm::LogInfo("XrdAdaptorInternal") << "Set monitoring ID to " << jobId << ".";
111  }
112 }
SendMonitoringInfoHandler nullHandler
string URL
Definition: rrClient.py:4
long long timeDiffMS ( const timespec &  a,
const timespec &  b 
)

Definition at line 59 of file XrdRequestManager.cc.

References mps_update::diff.

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

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

Definition at line 985 of file XrdRequestManager.cc.

References assert(), pileupDistInMC::total, and XRD_CL_MAX_CHUNK.

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

986 {
987  IOSize total = 0;
988  off_t last_offset = -1;
989  for (const auto & it : req)
990  {
991  total += it.size();
992  assert(it.offset() > last_offset);
993  last_offset = it.offset();
994  assert(it.size() <= XRD_CL_MAX_CHUNK);
995  assert(it.offset() < 0x1ffffffffff);
996  }
997  assert(req.size() <= 1024);
998  return total;
999 }
assert(m_qm.get())
#define XRD_CL_MAX_CHUNK
size_t IOSize
Definition: IOTypes.h:14

Variable Documentation

Definition at line 87 of file XrdRequestManager.cc.

Referenced by SendMonitoringInfo().