CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (RequestManager &manager, void *into, IOSize size, IOOffset off)
 
 ClientRequest (RequestManager &manager, std::shared_ptr< std::vector< IOPosBuffer > > iolist, IOSize size=0)
 
std::future< IOSizeget_future ()
 
size_t getCount () const
 
std::shared_ptr< Source const > getCurrentSource () const
 
std::shared_ptr< Source > & getCurrentSource ()
 
IOSize getSize () const
 
virtual void HandleResponse (XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
 
void setStatistics (std::shared_ptr< XrdReadStatistics > stats)
 
virtual ~ClientRequest ()
 

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

Constructor & Destructor Documentation

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),
31  m_into(into),
32  m_size(size),
33  m_off(off),
34  m_iolist(nullptr),
35  m_manager(manager)
36  {
37  }
edm::propagate_const< std::shared_ptr< std::vector< IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:92
RequestManager & m_manager
Definition: XrdRequest.h:93
tuple size
Write out results.
XrdAdaptor::ClientRequest::ClientRequest ( RequestManager manager,
std::shared_ptr< std::vector< IOPosBuffer > >  iolist,
IOSize  size = 0 
)
inline

Definition at line 39 of file XrdRequest.h.

References m_iolist, and m_size.

40  : m_failure_count(0),
41  m_into(nullptr),
42  m_size(size),
43  m_off(0),
44  m_iolist(iolist),
45  m_manager(manager)
46  {
47  if (m_iolist->size() && !m_size)
48  {
49  for (IOPosBuffer const & buf : *m_iolist)
50  {
51  m_size += buf.size();
52  }
53  }
54  }
edm::propagate_const< std::shared_ptr< std::vector< IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:92
RequestManager & m_manager
Definition: XrdRequest.h:93
tuple size
Write out results.
XrdAdaptor::ClientRequest::~ClientRequest ( )
virtual

Definition at line 21 of file XrdRequest.cc.

21 {}

Member Function Documentation

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

Definition at line 63 of file XrdRequest.h.

References m_promise.

64  {
65  return m_promise.get_future();
66  }
std::promise< IOSize > m_promise
Definition: XrdRequest.h:104
size_t XrdAdaptor::ClientRequest::getCount ( void  ) const
inline

Definition at line 75 of file XrdRequest.h.

References m_into, and m_iolist.

75 {return m_into ? 1 : m_iolist->size();}
edm::propagate_const< std::shared_ptr< std::vector< IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:92
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 81 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_source.

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:94
std::shared_ptr<Source>& XrdAdaptor::ClientRequest::getCurrentSource ( )
inline

Definition at line 82 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_source.

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:94
IOSize XrdAdaptor::ClientRequest::getSize ( ) const
inline

Definition at line 73 of file XrdRequest.h.

References m_size.

73 {return m_size;}
void XrdAdaptor::ClientRequest::HandleResponse ( XrdCl::XRootDStatus *  status,
XrdCl::AnyObject *  response 
)
overridevirtual

Handle the response from the Xrootd server.

Definition at line 24 of file XrdRequest.cc.

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

25 {
26  std::unique_ptr<XrdCl::AnyObject> response(resp);
27  std::unique_ptr<XrdCl::XRootDStatus> status(stat);
28  std::shared_ptr<ClientRequest> self_ref = self_reference();
29  m_self_reference = nullptr; // propagate_const<T> has no reset() function
30  {
32  m_qmw.swap(qmw);
33  }
34  m_stats = nullptr; // propagate_const<T> has no reset() function
35 
36  if ((!FAKE_ERROR_COUNTER || ((++g_fakeError % FAKE_ERROR_COUNTER) != 0)) && (status->IsOK() && resp))
37  {
38  if (m_into)
39  {
40  XrdCl::ChunkInfo *read_info;
41  response->Get(read_info);
42  m_promise.set_value(read_info->length);
43  }
44  else
45  {
46  XrdCl::VectorReadInfo *read_info;
47  response->Get(read_info);
48  m_promise.set_value(read_info->GetSize());
49  }
50  }
51  else
52  {
53  Source *source = m_source.get();
54  edm::LogWarning("XrdAdaptorInternal") << "XrdRequestManager::handle(name='"
55  << m_manager.getFilename() << ") failure when reading from "
56  << (source ? source->PrettyID() : "(unknown source)")
57  << "; failed with error '" << status->ToStr() << "' (errno="
58  << status->errNo << ", code=" << status->code << ").";
60  try
61  {
62  try
63  {
64  m_manager.requestFailure(self_ref, *status);
65  return;
66  }
67  catch (XrootdException& ex)
68  {
69  if (ex.getCode() == XrdCl::errInvalidResponse)
70  {
71  m_promise.set_exception(std::current_exception());
72  }
73  else throw;
74  }
75  }
76  catch (edm::Exception& ex)
77  {
78  ex.addContext("XrdAdaptor::ClientRequest::HandleResponse() failure while running connection recovery");
79  std::stringstream ss;
80  ss << "Original error: '" << status->ToStr() << "' (errno="
81  << status->errNo << ", code=" << status->code << ", source=" << (source ? source->PrettyID() : "(unknown source)") << ").";
82  ex.addAdditionalInfo(ss.str());
83  m_promise.set_exception(std::current_exception());
84  edm::LogWarning("XrdAdaptorInternal") << "Caught a CMSSW exception when running connection recovery.";
85  }
86  catch (std::exception)
87  {
89  ex << "XrdRequestManager::handle(name='" << m_manager.getFilename()
90  << ") failed with error '" << status->ToStr()
91  << "' (errno=" << status->errNo << ", code="
92  << status->code << "). Unknown exception occurred when running"
93  << " connection recovery.";
94  ex.addContext("Calling XrdRequestManager::handle()");
96  ex.addAdditionalInfo("Original source of error is " + (source ? source->PrettyID() : "(unknown source)"));
97  m_promise.set_exception(std::make_exception_ptr(ex));
98  edm::LogWarning("XrdAdaptorInternal") << "Caught a new exception when running connection recovery.";
99  }
100  }
101 }
const std::string & getFilename() const
const std::string & PrettyID() const
Definition: XrdSource.h:39
edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
Definition: XrdRequest.h:102
edm::propagate_const< std::shared_ptr< XrdReadStatistics > > m_stats
Definition: XrdRequest.h:95
void addConnections(cms::Exception &) const
QualityMetricWatch m_qmw
Definition: XrdRequest.h:106
void addAdditionalInfo(std::string const &info)
Definition: Exception.cc:235
std::shared_ptr< ClientRequest const > self_reference() const
Definition: XrdRequest.h:85
void requestFailure(std::shared_ptr< XrdAdaptor::ClientRequest > c_ptr, XrdCl::Status &c_status)
RequestManager & m_manager
Definition: XrdRequest.h:93
void addContext(std::string const &context)
Definition: Exception.cc:227
void swap(QualityMetricWatch &)
#define FAKE_ERROR_COUNTER
Definition: XrdRequest.cc:17
edm::propagate_const< std::shared_ptr< Source > > m_source
Definition: XrdRequest.h:94
std::promise< IOSize > m_promise
Definition: XrdRequest.h:104
static std::string const source
Definition: EdmProvDump.cc:43
static std::atomic< int > g_fakeError
Definition: XrdRequest.cc:18
tuple status
Definition: mps_update.py:57
std::shared_ptr<ClientRequest const> XrdAdaptor::ClientRequest::self_reference ( ) const
inlineprivate

Definition at line 85 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_self_reference.

edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
Definition: XrdRequest.h:102
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::shared_ptr<ClientRequest>& XrdAdaptor::ClientRequest::self_reference ( )
inlineprivate

Definition at line 86 of file XrdRequest.h.

References edm::get_underlying_safe(), and m_self_reference.

edm::propagate_const< std::shared_ptr< ClientRequest > > m_self_reference
Definition: XrdRequest.h:102
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void XrdAdaptor::ClientRequest::setStatistics ( std::shared_ptr< XrdReadStatistics stats)
inline

Definition at line 56 of file XrdRequest.h.

References m_stats.

57  {
58  m_stats = stats;
59  }
edm::propagate_const< std::shared_ptr< XrdReadStatistics > > m_stats
Definition: XrdRequest.h:95

Friends And Related Function Documentation

friend class Source
friend

Definition at line 25 of file XrdRequest.h.

Member Data Documentation

unsigned XrdAdaptor::ClientRequest::m_failure_count
private

Definition at line 88 of file XrdRequest.h.

void* XrdAdaptor::ClientRequest::m_into
private

Definition at line 89 of file XrdRequest.h.

Referenced by getCount().

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

Definition at line 92 of file XrdRequest.h.

Referenced by ClientRequest(), and getCount().

RequestManager& XrdAdaptor::ClientRequest::m_manager
private

Definition at line 93 of file XrdRequest.h.

IOOffset XrdAdaptor::ClientRequest::m_off
private

Definition at line 91 of file XrdRequest.h.

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

Definition at line 104 of file XrdRequest.h.

Referenced by get_future().

QualityMetricWatch XrdAdaptor::ClientRequest::m_qmw
private

Definition at line 106 of file XrdRequest.h.

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

Definition at line 102 of file XrdRequest.h.

Referenced by self_reference().

IOSize XrdAdaptor::ClientRequest::m_size
private

Definition at line 90 of file XrdRequest.h.

Referenced by ClientRequest(), and getSize().

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

Definition at line 94 of file XrdRequest.h.

Referenced by getCurrentSource().

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

Definition at line 95 of file XrdRequest.h.

Referenced by setStatistics().