CMS 3D CMS Logo

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

#include <XrdRequest.h>

Inheritance diagram for XrdAdaptor::ClientRequest:

Public Types

using IOOffset = edm::storage::IOOffset
 
using IOPosBuffer = edm::storage::IOPosBuffer
 
using IOSize = edm::storage::IOSize
 

Public Member Functions

 ClientRequest (const ClientRequest &)=delete
 
 ClientRequest (RequestManager &manager, void *into, IOSize size, IOOffset off)
 
 ClientRequest (RequestManager &manager, std::shared_ptr< std::vector< IOPosBuffer >> iolist, IOSize size=0)
 
std::future< edm::storage::IOSizeget_future ()
 
size_t getCount () const
 
std::shared_ptr< Source const > getCurrentSource () const
 
std::shared_ptr< Source > & getCurrentSource ()
 
edm::storage::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 const > self_reference () const
 
std::shared_ptr< ClientRequest > & self_reference ()
 

Private Attributes

unsigned m_failure_count
 
void * m_into
 
edm::propagate_const< std::shared_ptr< std::vector< edm::storage::IOPosBuffer > > > m_iolist
 
RequestManagerm_manager
 
edm::storage::IOOffset m_off
 
std::promise< edm::storage::IOSizem_promise
 
QualityMetricWatch m_qmw
 
edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
 
edm::storage::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.

Member Typedef Documentation

◆ IOOffset

Definition at line 28 of file XrdRequest.h.

◆ IOPosBuffer

Definition at line 26 of file XrdRequest.h.

◆ IOSize

Definition at line 27 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 33 of file XrdRequest.h.

34  : m_failure_count(0), m_into(into), m_size(size), m_off(off), m_iolist(nullptr), m_manager(manager) {}
size
Write out results.
edm::storage::IOOffset m_off
Definition: XrdRequest.h:74
edm::storage::IOSize m_size
Definition: XrdRequest.h:73
RequestManager & m_manager
Definition: XrdRequest.h:76
edm::propagate_const< std::shared_ptr< std::vector< edm::storage::IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:75

◆ ClientRequest() [3/3]

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

Definition at line 36 of file XrdRequest.h.

References visDQMUpload::buf, m_iolist, and m_size.

37  : m_failure_count(0), m_into(nullptr), m_size(size), m_off(0), m_iolist(iolist), m_manager(manager) {
38  if (!m_iolist->empty() && !m_size) {
39  for (edm::storage::IOPosBuffer const &buf : *m_iolist) {
40  m_size += buf.size();
41  }
42  }
43  }
size
Write out results.
edm::storage::IOOffset m_off
Definition: XrdRequest.h:74
edm::storage::IOSize m_size
Definition: XrdRequest.h:73
RequestManager & m_manager
Definition: XrdRequest.h:76
edm::propagate_const< std::shared_ptr< std::vector< edm::storage::IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:75

◆ ~ClientRequest()

XrdAdaptor::ClientRequest::~ClientRequest ( )
override

Definition at line 21 of file XrdRequest.cc.

21 {}

Member Function Documentation

◆ get_future()

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

Definition at line 49 of file XrdRequest.h.

References m_promise.

49 { return m_promise.get_future(); }
std::promise< edm::storage::IOSize > m_promise
Definition: XrdRequest.h:87

◆ getCount()

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

Definition at line 58 of file XrdRequest.h.

References m_into, and m_iolist.

58 { return m_into ? 1 : m_iolist->size(); }
edm::propagate_const< std::shared_ptr< std::vector< edm::storage::IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:75

◆ getCurrentSource() [1/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 64 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_source.

64 { return get_underlying_safe(m_source); }
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< Source > > m_source
Definition: XrdRequest.h:77

◆ getCurrentSource() [2/2]

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

Definition at line 65 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_source.

65 { return get_underlying_safe(m_source); }
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< Source > > m_source
Definition: XrdRequest.h:77

◆ getSize()

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

Definition at line 56 of file XrdRequest.h.

References m_size.

56 { return m_size; }
edm::storage::IOSize m_size
Definition: XrdRequest.h:73

◆ 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.

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

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 }
const std::string & getFilename() const
std::shared_ptr< ClientRequest const > self_reference() const
Definition: XrdRequest.h:68
edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
Definition: XrdRequest.h:85
edm::propagate_const< std::shared_ptr< XrdReadStatistics > > m_stats
Definition: XrdRequest.h:78
std::promise< edm::storage::IOSize > m_promise
Definition: XrdRequest.h:87
QualityMetricWatch m_qmw
Definition: XrdRequest.h:89
void addAdditionalInfo(std::string const &info)
Definition: Exception.cc:169
void addConnections(cms::Exception &) const
void requestFailure(std::shared_ptr< XrdAdaptor::ClientRequest > c_ptr, XrdCl::Status &c_status)
RequestManager & m_manager
Definition: XrdRequest.h:76
void addContext(std::string const &context)
Definition: Exception.cc:165
void swap(QualityMetricWatch &)
#define FAKE_ERROR_COUNTER
Definition: XrdRequest.cc:17
Log< level::Warning, false > LogWarning
edm::propagate_const< std::shared_ptr< Source > > m_source
Definition: XrdRequest.h:77
static std::string const source
Definition: EdmProvDump.cc:49
static std::atomic< int > g_fakeError
Definition: XrdRequest.cc:18

◆ operator=()

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

◆ self_reference() [1/2]

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

Definition at line 68 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_self_reference.

constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
Definition: XrdRequest.h:85

◆ self_reference() [2/2]

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

Definition at line 69 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_self_reference.

constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
Definition: XrdRequest.h:85

◆ setStatistics()

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

Definition at line 45 of file XrdRequest.h.

References m_stats, and dqmMemoryStats::stats.

45 { m_stats = stats; }
edm::propagate_const< std::shared_ptr< XrdReadStatistics > > m_stats
Definition: XrdRequest.h:78

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 71 of file XrdRequest.h.

◆ m_into

void* XrdAdaptor::ClientRequest::m_into
private

Definition at line 72 of file XrdRequest.h.

Referenced by getCount().

◆ m_iolist

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

Definition at line 75 of file XrdRequest.h.

Referenced by ClientRequest(), and getCount().

◆ m_manager

RequestManager& XrdAdaptor::ClientRequest::m_manager
private

Definition at line 76 of file XrdRequest.h.

◆ m_off

edm::storage::IOOffset XrdAdaptor::ClientRequest::m_off
private

Definition at line 74 of file XrdRequest.h.

◆ m_promise

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

Definition at line 87 of file XrdRequest.h.

Referenced by get_future().

◆ m_qmw

QualityMetricWatch XrdAdaptor::ClientRequest::m_qmw
private

Definition at line 89 of file XrdRequest.h.

◆ m_self_reference

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

Definition at line 85 of file XrdRequest.h.

Referenced by self_reference().

◆ m_size

edm::storage::IOSize XrdAdaptor::ClientRequest::m_size
private

Definition at line 73 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 77 of file XrdRequest.h.

Referenced by getCurrentSource().

◆ m_stats

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

Definition at line 78 of file XrdRequest.h.

Referenced by setStatistics().