ewmscp  ..
Public Member Functions | List of all members
outputHandler::davix::writerDavix Class Reference

#include <outputHandlerDavix.h>

Inheritance diagram for outputHandler::davix::writerDavix:
[legend]
Collaboration diagram for outputHandler::davix::writerDavix:
[legend]

Public Member Functions

 writerDavix (davix &aHandler, const std::string &aPath, copyRequest::stateType &state, bool noWrite)
 
void closeAndRemoveBadCopy () override
 
 ~writerDavix () noexcept(false) override
 
void writeBlock (const block &b) override
 
void doAttributePreservations (const genericStat &readInitialStat) override
 
void sync () 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 bool parallelizable () const
 tell if this handler is capable of parallel IO. Unsually not the case More...
 
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 13 of file outputHandlerDavix.h.

Constructor & Destructor Documentation

◆ writerDavix()

outputHandler::davix::writerDavix::writerDavix ( davix aHandler,
const std::string &  aPath,
copyRequest::stateType state,
bool  noWrite 
)

Definition at line 137 of file outputHandlerDavix.cpp.

140  :
141  davixIoCommon(aPath, aHandler) {
142  if (noWrite) {
143  fd = nullptr;
144  } else {
145  auto openMode = O_CREAT | O_WRONLY;
146  state.clear(copyRequest::stateBitType::append); // clear any old append sets, may be left over from former attempts
147  errorReport report(__func__, "open", path);
148  fd = handler.posix.open(&handler.params, path.c_str(), openMode, report);
149  if (fd == nullptr) {
150  report.throwUp();
151  }
152  }
153  };

References copyRequest::append, enumAsBitmask< T >::clear(), davixIoCommon::fd, davixIoCommon::handler, davixCommon::params, davixIoCommon::path, davixCommon::posix, and errorReport::throwUp().

Here is the call graph for this function:

◆ ~writerDavix()

outputHandler::davix::writerDavix::~writerDavix ( )
overridenoexcept

Definition at line 168 of file outputHandlerDavix.cpp.

168  {
169  if (fd != nullptr) {
170  if (isUnwinding()) {
172  return;
173  }
174  errorReport report(__func__, "close", path);
175  if (handler.posix.close(fd, report) != 0) {
176  report.throwUp();
177  }
178  }
179  };

References errorReport::throwUp().

Here is the call graph for this function:

Member Function Documentation

◆ closeAndRemoveBadCopy()

void outputHandler::davix::writerDavix::closeAndRemoveBadCopy ( )
override

Definition at line 154 of file outputHandlerDavix.cpp.

154  {
155  errorReport report(__func__, "close", path);
156  if (handler.posix.close(fd, report) != 0) {
158  path, "close during unwind ",
159  report.getMessage());
160  }
161  errorReport report2(__func__, "unlink", path);
163  path, "unlink failed copy", "due to exception");
164  if (handler.posix.unlink(&handler.params, path, report) != 0) {
165  report2.throwUp();
166  }
167  };

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

Here is the call graph for this function:

◆ doAttributePreservations()

void outputHandler::davix::writerDavix::doAttributePreservations ( const genericStat readInitialStat)
override

Definition at line 207 of file outputHandlerDavix.cpp.

207  {
208  // not supportted
209  }

◆ sync()

void outputHandler::davix::writerDavix::sync ( )
override

Definition at line 211 of file outputHandlerDavix.cpp.

211  {
212  throw std::runtime_error("sync not supported");
213  }

◆ writeBlock()

void outputHandler::davix::writerDavix::writeBlock ( const block b)
override

Definition at line 182 of file outputHandlerDavix.cpp.

182  {
183  size_t bytes_writen_so_far = 0;
184 
185  while (bytes_writen_so_far < b.size()) {
187  auto count = b.size() - bytes_writen_so_far;
188 
189  if (b.isHole()) { // just write zeroes
190  count = std::min({count, blockSize, block::nullBufferSize()});
191  } else {
192  count = std::min(count, blockSize);
193  }
194  errorReport report(__func__, "write", path);
195  auto bytes_writen = handler.posix.write(fd, b.bufferAt(bytes_writen_so_far), count, report);
196  if (bytes_writen < 0) {
197  report.throwUp();
198  }
199 
200  writeRateLimit.update(bytes_writen);
201  bytes_writen_so_far += bytes_writen;
202  }
203  }

References block::bufferAt(), block::isHole(), block::nullBufferSize(), block::size(), errorReport::throwUp(), throttle::watch::update(), throttle::watch::wait(), and writeRateLimit.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
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
block::isHole
bool isHole() const
Definition: block.h:36
errMsg::level::debug
@ debug
ioHandle::blockSize
size_t blockSize
in bytes, block size to be used when reading or writing
Definition: ioHandle.h:17
outputHandler::davix::writerDavix::closeAndRemoveBadCopy
void closeAndRemoveBadCopy() override
Definition: outputHandlerDavix.cpp:154
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
block::nullBufferSize
static size_t nullBufferSize()
Definition: block.cpp:34
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
block::size
size_t size() const
Definition: block.h:16
writeRateLimit
throttle::watch writeRateLimit
enumAsBitmask::clear
void clear(const T aBits)
Definition: enumAsBitmask.h:31
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
copyRequest::stateBitType::append
@ append