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 (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
 
void HandleResponse (XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
 
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< 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  }
size
Write out results.
edm::propagate_const< std::shared_ptr< std::vector< IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:92
RequestManager & m_manager
Definition: XrdRequest.h:93
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->empty() && !m_size)
48  {
49  for (IOPosBuffer const & buf : *m_iolist)
50  {
51  m_size += buf.size();
52  }
53  }
54  }
size
Write out results.
edm::propagate_const< std::shared_ptr< std::vector< IOPosBuffer > > > m_iolist
Definition: XrdRequest.h:92
RequestManager & m_manager
Definition: XrdRequest.h:93
XrdAdaptor::ClientRequest::~ClientRequest ( )
override

Definition at line 21 of file XrdRequest.cc.

Referenced by setStatistics().

21 {}

Member Function Documentation

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

Definition at line 63 of file XrdRequest.h.

References HandleResponse(), m_promise, and mps_update::status.

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 
)
override

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, mps_update::status, and XrdAdaptor::QualityMetricWatch::swap().

Referenced by get_future().

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  if( read_info == nullptr) {
44  ex<<"nullptr returned from response->Get().";
45  ex.addContext("XrdAdaptor::ClientRequest::HandleResponse() called." );
46  m_promise.set_exception( std::make_exception_ptr(ex));
47  return;
48  }
49  if( read_info->length == 0) {edm::LogWarning("XrdAdaptorInternal") << "XrdAdaptor::ClientRequest::HandleResponse: While reading from\n "
50  << m_manager.getFilename() << "\n received a read_info->length = 0 and read_info->offset = "<<read_info->offset;
51  }
52  m_promise.set_value(read_info->length);
53  }
54  else
55  {
56  XrdCl::VectorReadInfo *read_info;
57  response->Get(read_info);
58  if( read_info == nullptr) {
60  ex<<"nullptr returned from response->Get() from vector read.";
61  ex.addContext("XrdAdaptor::ClientRequest::HandleResponse() called." );
62  m_promise.set_exception( std::make_exception_ptr(ex));
63  return;
64  }
65  if( read_info->GetSize() == 0) {edm::LogWarning("XrdAdaptorInternal") << "XrdAdaptor::ClientRequest::HandleResponse: While reading from\n "
66  << m_manager.getFilename() << "\n received a read_info->GetSize() = 0";
67  }
68 
69  m_promise.set_value(read_info->GetSize());
70  }
71  }
72  else
73  {
74  Source *source = m_source.get();
75  edm::LogWarning("XrdAdaptorInternal") << "XrdRequestManager::handle(name='"
76  << m_manager.getFilename() << ") failure when reading from "
77  << (source ? source->PrettyID() : "(unknown source)")
78  << "; failed with error '" << status->ToStr() << "' (errno="
79  << status->errNo << ", code=" << status->code << ").";
81  try
82  {
83  try
84  {
85  m_manager.requestFailure(self_ref, *status);
86  return;
87  }
88  catch (XrootdException& ex)
89  {
90  if (ex.getCode() == XrdCl::errInvalidResponse)
91  {
92  m_promise.set_exception(std::current_exception());
93  }
94  else throw;
95  }
96  }
97  catch (edm::Exception& ex)
98  {
99  ex.addContext("XrdAdaptor::ClientRequest::HandleResponse() failure while running connection recovery");
100  std::stringstream ss;
101  ss << "Original error: '" << status->ToStr() << "' (errno="
102  << status->errNo << ", code=" << status->code << ", source=" << (source ? source->PrettyID() : "(unknown source)") << ").";
103  ex.addAdditionalInfo(ss.str());
104  m_promise.set_exception(std::current_exception());
105  edm::LogWarning("XrdAdaptorInternal") << "Caught a CMSSW exception when running connection recovery.";
106  }
107  catch (std::exception const&)
108  {
110  ex << "XrdRequestManager::handle(name='" << m_manager.getFilename()
111  << ") failed with error '" << status->ToStr()
112  << "' (errno=" << status->errNo << ", code="
113  << status->code << "). Unknown exception occurred when running"
114  << " connection recovery.";
115  ex.addContext("Calling XrdRequestManager::handle()");
117  ex.addAdditionalInfo("Original source of error is " + (source ? source->PrettyID() : "(unknown source)"));
118  m_promise.set_exception(std::make_exception_ptr(ex));
119  edm::LogWarning("XrdAdaptorInternal") << "Caught a new exception when running connection recovery.";
120  }
121  }
122 }
const std::string & getFilename() const
const std::string & PrettyID() const
Definition: XrdSource.h:40
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:169
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:165
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:47
static std::atomic< int > g_fakeError
Definition: XrdRequest.cc:18
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, and ~ClientRequest().

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().