CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
XrdAdaptor::ClientRequest Class Reference

#include <XrdRequest.h>

Inheritance diagram for XrdAdaptor::ClientRequest:

Public Member Functions

 ClientRequest (const ClientRequest &)=delete
 
 ClientRequest (RequestManager &manager, std::shared_ptr< std::vector< IOPosBuffer >> iolist, IOSize size=0)
 
 ClientRequest (RequestManager &manager, void *into, IOSize size, IOOffset off)
 
std::future< IOSizeget_future ()
 
size_t getCount () const
 
std::shared_ptr< Source > & getCurrentSource ()
 
std::shared_ptr< Source const > getCurrentSource () const
 
IOSize getSize () const
 
void HandleResponse (XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
 
ClientRequestoperator= (const ClientRequest &)=delete
 
void setStatistics (std::shared_ptr< XrdReadStatistics > stats)
 
 ~ClientRequest () override
 

Private Member Functions

std::shared_ptr< ClientRequest > & self_reference ()
 
std::shared_ptr< ClientRequest const > self_reference () const
 

Private Attributes

unsigned m_failure_count
 
void * m_into
 
edm::propagate_const< std::shared_ptr< std::vector< IOPosBuffer > > > m_iolist
 
RequestManagerm_manager
 
IOOffset m_off
 
std::promise< IOSizem_promise
 
QualityMetricWatch m_qmw
 
edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
 
IOSize m_size
 
edm::propagate_const< std::shared_ptr< Source > > m_source
 
edm::propagate_const< std::shared_ptr< XrdReadStatistics > > m_stats
 

Friends

class Source
 

Detailed Description

Definition at line 22 of file XrdRequest.h.

Constructor & Destructor Documentation

◆ ClientRequest() [1/3]

XrdAdaptor::ClientRequest::ClientRequest ( const ClientRequest )
delete

◆ ClientRequest() [2/3]

XrdAdaptor::ClientRequest::ClientRequest ( RequestManager manager,
void *  into,
IOSize  size,
IOOffset  off 
)
inline

Definition at line 29 of file XrdRequest.h.

30  : m_failure_count(0), m_into(into), m_size(size), m_off(off), m_iolist(nullptr), m_manager(manager) {}

◆ ClientRequest() [3/3]

XrdAdaptor::ClientRequest::ClientRequest ( RequestManager manager,
std::shared_ptr< std::vector< IOPosBuffer >>  iolist,
IOSize  size = 0 
)
inline

Definition at line 32 of file XrdRequest.h.

33  : m_failure_count(0), m_into(nullptr), m_size(size), m_off(0), m_iolist(iolist), m_manager(manager) {
34  if (!m_iolist->empty() && !m_size) {
35  for (IOPosBuffer const &buf : *m_iolist) {
36  m_size += buf.size();
37  }
38  }
39  }

References visDQMUpload::buf, m_iolist, and m_size.

◆ ~ClientRequest()

XrdAdaptor::ClientRequest::~ClientRequest ( )
override

Definition at line 21 of file XrdRequest.cc.

21 {}

Member Function Documentation

◆ get_future()

std::future<IOSize> XrdAdaptor::ClientRequest::get_future ( )
inline

Definition at line 45 of file XrdRequest.h.

45 { return m_promise.get_future(); }

References m_promise.

◆ getCount()

size_t XrdAdaptor::ClientRequest::getCount ( void  ) const
inline

Definition at line 54 of file XrdRequest.h.

54 { return m_into ? 1 : m_iolist->size(); }

References m_into, and m_iolist.

◆ getCurrentSource() [1/2]

std::shared_ptr<Source>& XrdAdaptor::ClientRequest::getCurrentSource ( )
inline

Definition at line 61 of file XrdRequest.h.

61 { return get_underlying_safe(m_source); }

References edm::get_underlying_safe(), and m_source.

◆ getCurrentSource() [2/2]

std::shared_ptr<Source const> XrdAdaptor::ClientRequest::getCurrentSource ( ) const
inline

Returns a pointer to the current source; may be nullptr if there is no outstanding IO

Definition at line 60 of file XrdRequest.h.

60 { return get_underlying_safe(m_source); }

References edm::get_underlying_safe(), and m_source.

◆ getSize()

IOSize XrdAdaptor::ClientRequest::getSize ( ) const
inline

Definition at line 52 of file XrdRequest.h.

52 { return m_size; }

References m_size.

◆ HandleResponse()

void XrdAdaptor::ClientRequest::HandleResponse ( XrdCl::XRootDStatus *  status,
XrdCl::AnyObject *  response 
)
override

Handle the response from the Xrootd server.

Definition at line 23 of file XrdRequest.cc.

23  {
24  std::unique_ptr<XrdCl::AnyObject> response(resp);
25  std::unique_ptr<XrdCl::XRootDStatus> status(stat);
26  std::shared_ptr<ClientRequest> self_ref = self_reference();
27  m_self_reference = nullptr; // propagate_const<T> has no reset() function
28  {
30  m_qmw.swap(qmw);
31  }
32  m_stats = nullptr; // propagate_const<T> has no reset() function
33 
34  if ((!FAKE_ERROR_COUNTER || ((++g_fakeError % FAKE_ERROR_COUNTER) != 0)) && (status->IsOK() && resp)) {
35  if (m_into) {
36  XrdCl::ChunkInfo *read_info;
37  response->Get(read_info);
38  if (read_info == nullptr) {
40  ex << "nullptr returned from response->Get().";
41  ex.addContext("XrdAdaptor::ClientRequest::HandleResponse() called.");
42  m_promise.set_exception(std::make_exception_ptr(ex));
43  return;
44  }
45  if (read_info->length == 0) {
46  edm::LogWarning("XrdAdaptorInternal")
47  << "XrdAdaptor::ClientRequest::HandleResponse: While reading from\n " << m_manager.getFilename()
48  << "\n received a read_info->length = 0 and read_info->offset = " << read_info->offset;
49  }
50  m_promise.set_value(read_info->length);
51  } else {
52  XrdCl::VectorReadInfo *read_info;
53  response->Get(read_info);
54  if (read_info == nullptr) {
56  ex << "nullptr returned from response->Get() from vector read.";
57  ex.addContext("XrdAdaptor::ClientRequest::HandleResponse() called.");
58  m_promise.set_exception(std::make_exception_ptr(ex));
59  return;
60  }
61  if (read_info->GetSize() == 0) {
62  edm::LogWarning("XrdAdaptorInternal") << "XrdAdaptor::ClientRequest::HandleResponse: While reading from\n "
63  << m_manager.getFilename() << "\n received a read_info->GetSize() = 0";
64  }
65 
66  m_promise.set_value(read_info->GetSize());
67  }
68  } else {
69  Source *source = m_source.get();
70  edm::LogWarning("XrdAdaptorInternal")
71  << "XrdRequestManager::handle(name='" << m_manager.getFilename() << ") failure when reading from "
72  << (source ? source->PrettyID() : "(unknown source)") << "; failed with error '" << status->ToStr()
73  << "' (errno=" << status->errNo << ", code=" << status->code << ").";
75  try {
76  try {
77  m_manager.requestFailure(self_ref, *status);
78  return;
79  } catch (XrootdException &ex) {
80  if (ex.getCode() == XrdCl::errInvalidResponse) {
81  m_promise.set_exception(std::current_exception());
82  } else
83  throw;
84  }
85  } catch (edm::Exception &ex) {
86  ex.addContext("XrdAdaptor::ClientRequest::HandleResponse() failure while running connection recovery");
87  std::stringstream ss;
88  ss << "Original error: '" << status->ToStr() << "' (errno=" << status->errNo << ", code=" << status->code
89  << ", source=" << (source ? source->PrettyID() : "(unknown source)") << ").";
90  ex.addAdditionalInfo(ss.str());
91  m_promise.set_exception(std::current_exception());
92  edm::LogWarning("XrdAdaptorInternal") << "Caught a CMSSW exception when running connection recovery.";
93  } catch (std::exception const &) {
95  ex << "XrdRequestManager::handle(name='" << m_manager.getFilename() << ") failed with error '" << status->ToStr()
96  << "' (errno=" << status->errNo << ", code=" << status->code << "). Unknown exception occurred when running"
97  << " connection recovery.";
98  ex.addContext("Calling XrdRequestManager::handle()");
100  ex.addAdditionalInfo("Original source of error is " + (source ? source->PrettyID() : "(unknown source)"));
101  m_promise.set_exception(std::make_exception_ptr(ex));
102  edm::LogWarning("XrdAdaptorInternal") << "Caught a new exception when running connection recovery.";
103  }
104  }
105 }

References cms::Exception::addAdditionalInfo(), cms::Exception::addContext(), cppFunctionSkipper::exception, FAKE_ERROR_COUNTER, edm::errors::FileReadError, g_fakeError, XrdAdaptor::XrootdException::getCode(), source, contentValuesCheck::ss, edm_modernize_messagelogger::stat, mps_update::status, and XrdAdaptor::QualityMetricWatch::swap().

◆ operator=()

ClientRequest& XrdAdaptor::ClientRequest::operator= ( const ClientRequest )
delete

◆ self_reference() [1/2]

std::shared_ptr<ClientRequest>& XrdAdaptor::ClientRequest::self_reference ( )
inlineprivate

Definition at line 65 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_self_reference.

◆ self_reference() [2/2]

std::shared_ptr<ClientRequest const> XrdAdaptor::ClientRequest::self_reference ( ) const
inlineprivate

Definition at line 64 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_self_reference.

◆ setStatistics()

void XrdAdaptor::ClientRequest::setStatistics ( std::shared_ptr< XrdReadStatistics stats)
inline

Definition at line 41 of file XrdRequest.h.

41 { m_stats = stats; }

References m_stats, and dqmMemoryStats::stats.

Friends And Related Function Documentation

◆ Source

friend class Source
friend

Definition at line 23 of file XrdRequest.h.

Member Data Documentation

◆ m_failure_count

unsigned XrdAdaptor::ClientRequest::m_failure_count
private

Definition at line 67 of file XrdRequest.h.

◆ m_into

void* XrdAdaptor::ClientRequest::m_into
private

Definition at line 68 of file XrdRequest.h.

Referenced by getCount().

◆ m_iolist

edm::propagate_const<std::shared_ptr<std::vector<IOPosBuffer> > > XrdAdaptor::ClientRequest::m_iolist
private

Definition at line 71 of file XrdRequest.h.

Referenced by ClientRequest(), and getCount().

◆ m_manager

RequestManager& XrdAdaptor::ClientRequest::m_manager
private

Definition at line 72 of file XrdRequest.h.

◆ m_off

IOOffset XrdAdaptor::ClientRequest::m_off
private

Definition at line 70 of file XrdRequest.h.

◆ m_promise

std::promise<IOSize> XrdAdaptor::ClientRequest::m_promise
private

Definition at line 83 of file XrdRequest.h.

Referenced by get_future().

◆ m_qmw

QualityMetricWatch XrdAdaptor::ClientRequest::m_qmw
private

Definition at line 85 of file XrdRequest.h.

◆ m_self_reference

edm::propagate_const<std::shared_ptr<ClientRequest> > XrdAdaptor::ClientRequest::m_self_reference
private

Definition at line 81 of file XrdRequest.h.

Referenced by self_reference().

◆ m_size

IOSize XrdAdaptor::ClientRequest::m_size
private

Definition at line 69 of file XrdRequest.h.

Referenced by ClientRequest(), and getSize().

◆ m_source

edm::propagate_const<std::shared_ptr<Source> > XrdAdaptor::ClientRequest::m_source
private

Definition at line 73 of file XrdRequest.h.

Referenced by getCurrentSource().

◆ m_stats

edm::propagate_const<std::shared_ptr<XrdReadStatistics> > XrdAdaptor::ClientRequest::m_stats
private

Definition at line 74 of file XrdRequest.h.

Referenced by setStatistics().

FAKE_ERROR_COUNTER
#define FAKE_ERROR_COUNTER
Definition: XrdRequest.cc:17
XrdAdaptor::ClientRequest::m_source
edm::propagate_const< std::shared_ptr< Source > > m_source
Definition: XrdRequest.h:73
XrdAdaptor::ClientRequest::self_reference
std::shared_ptr< ClientRequest const > self_reference() const
Definition: XrdRequest.h:64
cms::Exception::addContext
void addContext(std::string const &context)
Definition: Exception.cc:165
XrdAdaptor::RequestManager::addConnections
void addConnections(cms::Exception &) const
Definition: XrdRequestManager.cc:488
XrdAdaptor::ClientRequest::m_iolist
edm::propagate_const< std::shared_ptr< std::vector< IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:71
mps_update.status
status
Definition: mps_update.py:69
g_fakeError
static std::atomic< int > g_fakeError
Definition: XrdRequest.cc:18
XrdAdaptor::XrootdException::getCode
uint16_t getCode()
Definition: XrdRequestManager.h:38
XrdAdaptor::ClientRequest::m_failure_count
unsigned m_failure_count
Definition: XrdRequest.h:67
XrdAdaptor::ClientRequest::m_into
void * m_into
Definition: XrdRequest.h:68
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
XrdAdaptor::ClientRequest::m_qmw
QualityMetricWatch m_qmw
Definition: XrdRequest.h:85
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::Exception
Definition: EDMException.h:77
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
XrdAdaptor::QualityMetricWatch
Definition: QualityMetric.h:20
source
static const std::string source
Definition: EdmProvDump.cc:47
XrdAdaptor::RequestManager::getFilename
const std::string & getFilename() const
Definition: XrdRequestManager.h:103
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
XrdAdaptor::ClientRequest::m_off
IOOffset m_off
Definition: XrdRequest.h:70
XrdAdaptor::ClientRequest::m_stats
edm::propagate_const< std::shared_ptr< XrdReadStatistics > > m_stats
Definition: XrdRequest.h:74
XrdAdaptor::ClientRequest::m_size
IOSize m_size
Definition: XrdRequest.h:69
cms::Exception::addAdditionalInfo
void addAdditionalInfo(std::string const &info)
Definition: Exception.cc:169
dqmMemoryStats.stats
stats
Definition: dqmMemoryStats.py:134
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
XrdAdaptor::Source
Definition: XrdSource.h:23
XrdAdaptor::QualityMetricWatch::swap
void swap(QualityMetricWatch &)
Definition: QualityMetric.cc:55
IOPosBuffer
Definition: IOPosBuffer.h:7
XrdAdaptor::XrootdException
Definition: XrdRequestManager.h:31
XrdAdaptor::ClientRequest::m_promise
std::promise< IOSize > m_promise
Definition: XrdRequest.h:83
XrdAdaptor::ClientRequest::m_self_reference
edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
Definition: XrdRequest.h:81
XrdAdaptor::ClientRequest::m_manager
RequestManager & m_manager
Definition: XrdRequest.h:72
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
edm::errors::FileReadError
Definition: EDMException.h:50
XrdAdaptor::RequestManager::requestFailure
void requestFailure(std::shared_ptr< XrdAdaptor::ClientRequest > c_ptr, XrdCl::Status &c_status)
Definition: XrdRequestManager.cc:720
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443