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 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< SourcegetCurrentSource () const
 
IOSize getSize () const
 
virtual void HandleResponse (XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
 
void setStatistics (std::shared_ptr< XrdReadStatistics > stats)
 
virtual ~ClientRequest ()
 

Private Attributes

unsigned m_failure_count
 
void * m_into
 
std::shared_ptr< std::vector
< IOPosBuffer > > 
m_iolist
 
RequestManagerm_manager
 
IOOffset m_off
 
std::promise< IOSizem_promise
 
QualityMetricWatch m_qmw
 
std::shared_ptr< ClientRequestm_self_reference
 
IOSize m_size
 
std::shared_ptr< Sourcem_source
 
std::shared_ptr
< XrdReadStatistics
m_stats
 

Friends

class Source
 

Detailed Description

Definition at line 22 of file XrdRequest.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file XrdRequest.h.

29  : m_failure_count(0),
30  m_into(into),
31  m_size(size),
32  m_off(off),
33  m_iolist(nullptr),
34  m_manager(manager)
35  {
36  }
RequestManager & m_manager
Definition: XrdRequest.h:88
std::shared_ptr< std::vector< IOPosBuffer > > m_iolist
Definition: XrdRequest.h:87
tuple size
Write out results.
XrdAdaptor::ClientRequest::ClientRequest ( RequestManager manager,
std::shared_ptr< std::vector< IOPosBuffer > >  iolist,
IOSize  size = 0 
)
inline

Definition at line 38 of file XrdRequest.h.

References m_iolist, and m_size.

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

Definition at line 20 of file XrdRequest.cc.

20 {}

Member Function Documentation

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

Definition at line 62 of file XrdRequest.h.

References m_promise.

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

Definition at line 74 of file XrdRequest.h.

References m_into, and m_iolist.

74 {return m_into ? 1 : m_iolist->size();}
std::shared_ptr< std::vector< IOPosBuffer > > m_iolist
Definition: XrdRequest.h:87
std::shared_ptr<Source> XrdAdaptor::ClientRequest::getCurrentSource ( ) const
inline

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

Definition at line 80 of file XrdRequest.h.

References m_source.

80 {return m_source;}
std::shared_ptr< Source > m_source
Definition: XrdRequest.h:89
IOSize XrdAdaptor::ClientRequest::getSize ( ) const
inline

Definition at line 72 of file XrdRequest.h.

References m_size.

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

Handle the response from the Xrootd server.

Definition at line 23 of file XrdRequest.cc.

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

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

Definition at line 55 of file XrdRequest.h.

References m_stats.

56  {
57  m_stats = stats;
58  }
std::shared_ptr< XrdReadStatistics > m_stats
Definition: XrdRequest.h:90

Friends And Related Function Documentation

friend class Source
friend

Definition at line 24 of file XrdRequest.h.

Member Data Documentation

unsigned XrdAdaptor::ClientRequest::m_failure_count
private

Definition at line 83 of file XrdRequest.h.

void* XrdAdaptor::ClientRequest::m_into
private

Definition at line 84 of file XrdRequest.h.

Referenced by getCount().

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

Definition at line 87 of file XrdRequest.h.

Referenced by ClientRequest(), and getCount().

RequestManager& XrdAdaptor::ClientRequest::m_manager
private

Definition at line 88 of file XrdRequest.h.

IOOffset XrdAdaptor::ClientRequest::m_off
private

Definition at line 86 of file XrdRequest.h.

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

Definition at line 99 of file XrdRequest.h.

Referenced by get_future().

QualityMetricWatch XrdAdaptor::ClientRequest::m_qmw
private

Definition at line 101 of file XrdRequest.h.

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

Definition at line 97 of file XrdRequest.h.

IOSize XrdAdaptor::ClientRequest::m_size
private

Definition at line 85 of file XrdRequest.h.

Referenced by ClientRequest(), and getSize().

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

Definition at line 89 of file XrdRequest.h.

Referenced by getCurrentSource().

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

Definition at line 90 of file XrdRequest.h.

Referenced by setStatistics().