Loading...
Searching...
No Matches
XrdCephOssBufferedFile.hh
Go to the documentation of this file.
//------------------------------------------------------------------------------
// Copyright (c) 2014-2015 by European Organization for Nuclear Research (CERN)
// Author: Sebastien Ponce <sebastien.ponce@cern.ch>
//------------------------------------------------------------------------------
// This file is part of the XRootD software suite.
//
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//
// In applying this licence, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//------------------------------------------------------------------------------
#ifndef __XRD_CEPH_OSS_BUFFERED_FILE_HH__
#define __XRD_CEPH_OSS_BUFFERED_FILE_HH__
#include "XrdOss/XrdOss.hh"
#include "XrdCeph/XrdCephOss.hh"
#include "XrdCeph/XrdCephOssFile.hh"
#include "XrdCeph/XrdCephBuffers/IXrdCephBufferData.hh"
#include "XrdCeph/XrdCephBuffers/IXrdCephBufferAlg.hh"
#include "XrdCeph/XrdCephBuffers/IXrdCephReadVAdapter.hh"
#include <memory>
#include <chrono>
#include <atomic>
#include <map>
#include <mutex>
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class XrdCephOssBufferedFile : virtual public XrdCephOssFile { // XrdOssDF
public:
XrdCephOssBufferedFile(XrdCephOss *cephoss,XrdCephOssFile *cephossDF, size_t buffersize,
const std::string& bufferIOmode,
size_t maxNumberSimulBuffers);
//explicit XrdCephOssBufferedFile(size_t buffersize);
virtual ~XrdCephOssBufferedFile();
virtual int Open(const char *path, int flags, mode_t mode, XrdOucEnv &env);
virtual int Close(long long *retsz=0);
virtual ssize_t Read(off_t offset, size_t blen);
virtual ssize_t Read(void *buff, off_t offset, size_t blen);
virtual int Read(XrdSfsAio *aoip);
virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt);
virtual ssize_t ReadRaw(void *, off_t, size_t);
virtual int Fstat(struct stat *buff);
virtual ssize_t Write(const void *buff, off_t offset, size_t blen);
virtual int Write(XrdSfsAio *aiop);
virtual int Fsync(void);
virtual int Ftruncate(unsigned long long);
protected:
std::unique_ptr<XrdCephBuffer::IXrdCephBufferAlg> createBuffer();
XrdCephOss *m_cephoss = nullptr;
XrdCephOssFile * m_xrdOssDF = nullptr; // holder of the XrdCephOssFile instance
std::unique_ptr<XrdCephBuffer::IXrdCephBufferAlg> m_bufferAlg;
std::map<size_t, std::unique_ptr<XrdCephBuffer::IXrdCephBufferAlg> > m_bufferReadAlgs;
std::mutex m_buf_mutex;
size_t m_maxCountReadBuffers {10};
int m_maxBufferRetries {5};
int m_maxBufferRetrySleepTime_ms;
int m_flags = 0;
size_t m_bufsize = 16*1024*1024L; // default 16MiB size
std::string m_bufferIOmode;
std::string m_path;
std::chrono::time_point<std::chrono::system_clock> m_timestart;
std::atomic<size_t> m_bytesRead = {0};
std::atomic<size_t> m_bytesReadV = {0};
std::atomic<size_t> m_bytesReadAIO = {0};
std::atomic<size_t> m_bytesWrite = {0};
std::atomic<size_t> m_bytesWriteAIO= {0};
};
#endif /* __XRD_CEPH_OSS_BUFFERED_FILE_HH__ */
IXrdCephBufferAlg.hh
IXrdCephBufferData.hh
IXrdCephReadVAdapter.hh
XrdCephOssFile.hh
XrdCephOss.hh
XrdOss.hh
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdCephOssBufferedFile::m_bufferIOmode
std::string m_bufferIOmode
Definition XrdCephOssBufferedFile.hh:85
XrdCephOssBufferedFile::m_bufferReadAlgs
std::map< size_t, std::unique_ptr< XrdCephBuffer::IXrdCephBufferAlg > > m_bufferReadAlgs
Definition XrdCephOssBufferedFile.hh:75
XrdCephOssBufferedFile::m_bytesRead
std::atomic< size_t > m_bytesRead
Definition XrdCephOssBufferedFile.hh:88
XrdCephOssBufferedFile::Ftruncate
virtual int Ftruncate(unsigned long long)
Definition XrdCephOssBufferedFile.cc:308
XrdCephOssBufferedFile::m_timestart
std::chrono::time_point< std::chrono::system_clock > m_timestart
Definition XrdCephOssBufferedFile.hh:87
XrdCephOssBufferedFile::m_buf_mutex
std::mutex m_buf_mutex
Definition XrdCephOssBufferedFile.hh:76
XrdCephOssBufferedFile::m_maxBufferRetrySleepTime_ms
int m_maxBufferRetrySleepTime_ms
How many times to retry a ready from a buffer with EBUSY errors.
Definition XrdCephOssBufferedFile.hh:81
XrdCephOssBufferedFile::m_maxBufferRetries
int m_maxBufferRetries
set the maximum of buffers to open on a single instance (e.g. for simultaneous file reads)
Definition XrdCephOssBufferedFile.hh:80
XrdCephOssBufferedFile::Open
virtual int Open(const char *path, int flags, mode_t mode, XrdOucEnv &env)
Definition XrdCephOssBufferedFile.cc:82
XrdCephOssBufferedFile::Fstat
virtual int Fstat(struct stat *buff)
Definition XrdCephOssBufferedFile.cc:240
XrdCephOssBufferedFile::m_bytesReadV
std::atomic< size_t > m_bytesReadV
number of bytes read or written
Definition XrdCephOssBufferedFile.hh:89
XrdCephOssBufferedFile::m_bytesWrite
std::atomic< size_t > m_bytesWrite
number of bytes read or written
Definition XrdCephOssBufferedFile.hh:91
XrdCephOssBufferedFile::~XrdCephOssBufferedFile
virtual ~XrdCephOssBufferedFile()
Definition XrdCephOssBufferedFile.cc:70
XrdCephOssBufferedFile::m_bufferAlg
std::unique_ptr< XrdCephBuffer::IXrdCephBufferAlg > m_bufferAlg
Definition XrdCephOssBufferedFile.hh:74
XrdCephOssBufferedFile::m_cephoss
XrdCephOss * m_cephoss
create a new instance of the buffer
Definition XrdCephOssBufferedFile.hh:72
XrdCephOssBufferedFile::Write
virtual ssize_t Write(const void *buff, off_t offset, size_t blen)
Definition XrdCephOssBufferedFile.cc:244
XrdCephOssBufferedFile::Fsync
virtual int Fsync(void)
Definition XrdCephOssBufferedFile.cc:304
XrdCephOssBufferedFile::m_bytesReadAIO
std::atomic< size_t > m_bytesReadAIO
number of bytes read or written
Definition XrdCephOssBufferedFile.hh:90
XrdCephOssBufferedFile::m_bytesWriteAIO
std::atomic< size_t > m_bytesWriteAIO
number of bytes read or written
Definition XrdCephOssBufferedFile.hh:92
XrdCephOssBufferedFile::m_path
std::string m_path
Definition XrdCephOssBufferedFile.hh:86
XrdCephOssBufferedFile::ReadV
virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt)
Definition XrdCephOssBufferedFile.cc:140
XrdCephOssBufferedFile::m_bufsize
size_t m_bufsize
Definition XrdCephOssBufferedFile.hh:84
XrdCephOssBufferedFile::Read
virtual ssize_t Read(off_t offset, size_t blen)
Definition XrdCephOssBufferedFile.cc:147
XrdCephOssBufferedFile::Close
virtual int Close(long long *retsz=0)
Definition XrdCephOssBufferedFile.cc:101
XrdCephOssBufferedFile::m_flags
int m_flags
number of ms to sleep if a retry is requested
Definition XrdCephOssBufferedFile.hh:83
XrdCephOssBufferedFile::m_xrdOssDF
XrdCephOssFile * m_xrdOssDF
Definition XrdCephOssBufferedFile.hh:73
XrdCephOssBufferedFile::m_maxCountReadBuffers
size_t m_maxCountReadBuffers
any data access method on the buffer will use this
Definition XrdCephOssBufferedFile.hh:77
XrdCephOssBufferedFile::ReadRaw
virtual ssize_t ReadRaw(void *, off_t, size_t)
Definition XrdCephOssBufferedFile.cc:235
XrdCephOssBufferedFile::createBuffer
std::unique_ptr< XrdCephBuffer::IXrdCephBufferAlg > createBuffer()
Definition XrdCephOssBufferedFile.cc:313
XrdCephOssBufferedFile::XrdCephOssBufferedFile
XrdCephOssBufferedFile(XrdCephOss *cephoss, XrdCephOssFile *cephossDF, size_t buffersize, const std::string &bufferIOmode, size_t maxNumberSimulBuffers)
Definition XrdCephOssBufferedFile.cc:58
XrdCephOssFile::XrdCephOssFile
XrdCephOssFile(XrdCephOss *cephoss)
Definition XrdCephOssFile.cc:39
XrdCephOss
Definition XrdCephOss.hh:55
XrdOucEnv
Definition XrdOucEnv.hh:42
XrdSfsAio
Definition XrdSfsAio.hh:59
XrdOucIOVec
Definition XrdOucIOVec.hh:41