ewmscp  ..
Public Member Functions | List of all members
inputHandler::davix::readerDavix Class Reference

#include <inputHandlerDavix.h>

Inheritance diagram for inputHandler::davix::readerDavix:
[legend]
Collaboration diagram for inputHandler::davix::readerDavix:
[legend]

Public Member Functions

 readerDavix (davixCommon &aHandler, const std::string &aPath, copyRequest::stateType &state, const genericStat &inititalStat)
 
 ~readerDavix () noexcept(false) override
 
bool readBlock (block &b) override
 
void readBlockP (block &b, size_t bytesToRead, off_t offset) override
 
bool parallelizable () const override
 tell if this handler is capable of parallel IO. Unsually not the case More...
 
void checkUnchangedness () override
 
- Public Member Functions inherited from davixIoCommon
 davixIoCommon (const std::string &aPath, davixCommon &aHandler)
 
std::unique_ptr< const genericStatgetStat () override
 
- Public Member Functions inherited from ioHandle
 ioHandle ()
 
virtual ~ioHandle () noexcept(false)
 
virtual void setXattr (const std::string &, const std::string &)
 
virtual std::string getXattr (const std::string &)
 get one extended attribute value More...
 
virtual void removeXattr (const std::string &)
 
virtual size_t getBlockSize () const
 
virtual void setBlockSize (size_t newSize)
 
virtual std::unique_ptr< attrDataTypegetAttrData (const outputHandler::base *)
 get attributes in the optimal way for setting with aOutputHandler More...
 
virtual std::unique_ptr< acl::listgetAclData ()
 get acls More...
 

Additional Inherited Members

- Protected Attributes inherited from davixIoCommon
const std::string & path
 
davixCommonhandler
 
DAVIX_FD * fd
 
- Protected Attributes inherited from ioHandle
size_t blockSize
 in bytes, block size to be used when reading or writing More...
 

Detailed Description

Definition at line 16 of file inputHandlerDavix.h.

Constructor & Destructor Documentation

◆ readerDavix()

inputHandler::davix::readerDavix::readerDavix ( davixCommon aHandler,
const std::string &  aPath,
copyRequest::stateType state,
const genericStat inititalStat 
)

Definition at line 60 of file inputHandlerDavix.cpp.

63  :
64  davixIoCommon(aPath, aHandler),
65  reader(inititalStat) {
66  errorReport report(__func__, "open", path);
67  fd = handler.posix.open(&handler.params, path.c_str(), O_RDONLY, report);
68  if (fd == nullptr) {
69  if (report->getStatus() == Davix::StatusCode::FileNotFound) {
71  }
72  report.throwUp();
73  }
74  blockSize = readInitialStat.blksize;
75  }

References ioHandle::blockSize, davixIoCommon::fd, davixIoCommon::handler, davixCommon::params, davixIoCommon::path, davixCommon::posix, errorReport::throwUp(), and copyRequest::vanished.

Here is the call graph for this function:

◆ ~readerDavix()

inputHandler::davix::readerDavix::~readerDavix ( )
overridenoexcept

Definition at line 76 of file inputHandlerDavix.cpp.

76  {
77  if (fd) {
78  errorReport report(__func__, "close", path);
79  if (handler.posix.close(fd, report) != 0) {
80  if (isUnwinding()) {
82  path, "close during unwind ",
83  report.getMessage());
84  return;
85  }
86  report.throwUp();
87  }
88  }
89  }

References errMsg::debug, errMsg::emit(), errorReport::getMessage(), and errorReport::throwUp().

Here is the call graph for this function:

Member Function Documentation

◆ checkUnchangedness()

void inputHandler::davix::readerDavix::checkUnchangedness ( )
override

Definition at line 158 of file inputHandlerDavix.cpp.

158  {
159  };

◆ parallelizable()

bool inputHandler::davix::readerDavix::parallelizable ( ) const
overridevirtual

tell if this handler is capable of parallel IO. Unsually not the case

Reimplemented from ioHandle.

Definition at line 129 of file inputHandlerDavix.cpp.

129  {
130  return true;
131  }

◆ readBlock()

bool inputHandler::davix::readerDavix::readBlock ( block b)
override

Definition at line 92 of file inputHandlerDavix.cpp.

92  {
93  b.clear(totalBytesRead);
94  bool lastblock = false;
95  while (b.size() + blockSize <= b.max_size()) {
97  errorReport report(__func__, "read", path);
98  timerInst(read);
99  auto bytes_read = handler.posix.read(fd, b.bufferAt(b.size()), blockSize, report);
100  if (bytes_read < 0) {
101  report.throwUp();
102  }
103  if (bytes_read == 0) {
104  lastblock = true;
105  if (totalBytesRead < readInitialStat.size) {
106  throw delayAdvisingError(path + " has shrunk while reading, (" +
107  std::to_string(readInitialStat.size) +
108  " -> " +
109  std::to_string(totalBytesRead) +
110  ")");
111  }
112  break;
113  }
114  readRateLimit.update(bytes_read);
115  totalBytesRead += bytes_read;
116  if (totalBytesRead > readInitialStat.size) {
117  throw delayAdvisingError(path + " has grown while reading, (" +
118  std::to_string(readInitialStat.size) +
119  " -> " +
120  std::to_string(totalBytesRead) +
121  ")");
122  }
123  b.bump_size(bytes_read);
124  }
125 
126  return lastblock;
127  };

References block::bufferAt(), block::bump_size(), block::clear(), block::max_size(), readRateLimit, block::size(), errorReport::throwUp(), timerInst, throttle::watch::update(), and throttle::watch::wait().

Here is the call graph for this function:

◆ readBlockP()

void inputHandler::davix::readerDavix::readBlockP ( block b,
size_t  bytesToRead,
off_t  offset 
)
override

Definition at line 133 of file inputHandlerDavix.cpp.

133  {
134  b.clear(offset);
135  while (b.size() + blockSize <= b.max_size()) {
136  errorReport report(__func__, "pread", path);
137  timerInst(pread);
138  auto bytes_read = handler.posix.pread64(fd, b.bufferAt(b.size()), blockSize, offset + b.size(),report);
139  if (bytes_read < 0)
140  report.throwUp();
141  if (bytes_read == 0) {
142  break;
143  }
144  b.bump_size(bytes_read);
145  if (b.size() > bytesToRead) {
146  throw delayAdvisingError(path + " has grown while reading");
147  }
148  }
149  if (b.size() < bytesToRead) {
150  throw delayAdvisingError(path + " has shrunk while reading "
151  + std::to_string(bytesToRead)
152  + " "
153  + std::to_string(b.size()));
154  }
155  }

References block::bufferAt(), block::bump_size(), block::clear(), block::max_size(), block::size(), errorReport::throwUp(), and timerInst.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
delayAdvisingError
class for exceptions that advise for delays Exceptions of this kind are to be thrown when circumstanc...
Definition: inputHandler.h:22
block::max_size
size_t max_size() const
Definition: block.h:22
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
davixIoCommon::fd
DAVIX_FD * fd
Definition: davixCommon.h:228
copyRequest::stateBitType::vanished
@ vanished
block::bump_size
void bump_size(size_t additionalBytes)
Definition: block.h:33
readRateLimit
throttle::watch readRateLimit
errMsg::level::debug
@ debug
ioHandle::blockSize
size_t blockSize
in bytes, block size to be used when reading or writing
Definition: ioHandle.h:17
block::bufferAt
void * bufferAt(size_t offset)
only way to access the data in the block
Definition: block.cpp:28
errorReport
class for easy error handling with davix ensures proper cleanup of the error report when going out of...
Definition: davixCommon.h:12
davixIoCommon::handler
davixCommon & handler
Definition: davixCommon.h:227
davixCommon::posix
Davix::DavPosix posix
Definition: davixCommon.h:198
davixIoCommon::davixIoCommon
davixIoCommon(const std::string &aPath, davixCommon &aHandler)
Definition: davixCommon.cpp:214
throttle::watch::wait
void wait()
Definition: throttle.h:50
errMsg::emit
void emit(level aLogLevel, const location &loc, const std::string &aObject, const std::string &aAction, const Args &... args)
function to create and enqueue a message, this is the only way that messages should be created!
Definition: errMsgQueue.h:148
timerInst
#define timerInst(subfunc)
Definition: timer.h:157
block::size
size_t size() const
Definition: block.h:16
block::clear
void clear(size_t aOffset)
Definition: block.h:28
davixCommon::params
Davix::RequestParams params
Definition: davixCommon.h:197
throttle::watch::update
void update(double units=1.0)
Definition: throttle.h:35
davixIoCommon::path
const std::string & path
Definition: davixCommon.h:226