xrootd
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
XrdFileCache::Prefetch Class Reference

Downloads data into a file on local disk and handles IO read requests. More...

#include <XrdFileCachePrefetch.hh>

Collaboration diagram for XrdFileCache::Prefetch:
Collaboration graph
[legend]

Classes

struct  RAM
 
struct  RAMBlock
 
struct  Task
 A prefetching task – a file region that requires preferential treatment. More...
 

Public Member Functions

 Prefetch (XrdOucCacheIO &inputFile, std::string &path, long long offset, long long fileSize)
 Constructor. More...
 
 ~Prefetch ()
 Destructor. More...
 
void Run ()
 Thread function for file prefetching. More...
 
StatsGetStats ()
 Reference to prefetch statistics. More...
 
void WriteBlockToDisk (int ramIdx, size_t size)
 Write block to file on disk. Called from Cache. More...
 
void DecRamBlockRefCount (int ramIdx)
 Decrease block reference count. More...
 
bool InitiateClose ()
 Initiate close. Return true if still IO active. Used in XrdPosixXrootd::Close() More...
 
void Sync ()
 Sync file cache inf o and output data with disk. More...
 

Protected Member Functions

ssize_t Read (char *buff, off_t offset, size_t size)
 Read from disk, RAM, task, or client. More...
 
int ReadV (const XrdOucIOVec *readV, int n)
 Vector read from disk if block is already downloaded, else ReadV from client. More...
 
void AppendIOStatToFileInfo ()
 Write cache statistics in *cinfo file. More...
 

Private Types

enum  ReadRamState_t { kReadWait, kReadSuccess, kReadFailed }
 

Private Member Functions

void CloseCleanly ()
 Stop Run thread. More...
 
TaskGetNextTask ()
 Get blocks to prefetch. More...
 
bool Open ()
 Open file handle for data file and info file on local disk. More...
 
XrdCl::Log * clLog () const
 Short log alias. More...
 
ssize_t ReadInBlocks (char *buff, off_t offset, size_t size)
 Split read in blocks. More...
 
TaskCreateTaskForFirstUndownloadedBlock ()
 Prefetch block. More...
 
bool ReadFromTask (int bIdx, char *buff, long long off, size_t size)
 Create task from read request and wait its completed. More...
 
void DoTask (Task *task)
 Read from client into in memory cache, queue ram buffer for disk write. More...
 
const char * lPath () const
 Log path. More...
 

Private Attributes

RAM m_ram
 in memory cache More...
 
XrdOssDFm_output
 file handle for data file on disk More...
 
XrdOssDFm_infoFile
 file handle for data-info file on disk More...
 
Info m_cfi
 download status of file blocks and access statistics More...
 
XrdOucCacheIOm_input
 original data source More...
 
std::string m_temp_filename
 filename of data file on disk More...
 
long long m_offset
 offset of disk file for block-based operation More...
 
long long m_fileSize
 size of disk file for block-based operation More...
 
bool m_started
 state of run thread More...
 
bool m_failed
 reading from original source or writing to disk has failed More...
 
bool m_stopping
 run thread should be stopped More...
 
bool m_stopped
 prefetch is stopped More...
 
XrdSysCondVar m_stateCond
 state condition variable More...
 
XrdSysMutex m_downloadStatusMutex
 mutex locking access to m_cfi object More...
 
std::deque< Task * > m_tasks_queue
 download queue More...
 
XrdSysCondVar m_queueCond
 m_tasks_queue condition variable More...
 
Stats m_stats
 cache statistics, used in IO detach More...
 
XrdSysMutex m_syncStatusMutex
 mutex locking fsync status More...
 
XrdJobm_syncer
 
std::vector< int > m_writes_during_sync
 
int m_non_flushed_cnt
 
bool m_in_sync
 

Friends

class IOEntireFile
 
class IOFileBlock
 

Detailed Description

Downloads data into a file on local disk and handles IO read requests.

Member Enumeration Documentation

Enumerator
kReadWait 
kReadSuccess 
kReadFailed 

Constructor & Destructor Documentation

XrdFileCache::Prefetch::Prefetch ( XrdOucCacheIO inputFile,
std::string &  path,
long long  offset,
long long  fileSize 
)

Constructor.

XrdFileCache::Prefetch::~Prefetch ( )

Destructor.

Member Function Documentation

void XrdFileCache::Prefetch::AppendIOStatToFileInfo ( )
protected

Write cache statistics in *cinfo file.

XrdCl::Log* XrdFileCache::Prefetch::clLog ( ) const
inlineprivate

Short log alias.

References XrdCl::DefaultEnv::GetLog().

void XrdFileCache::Prefetch::CloseCleanly ( )
private

Stop Run thread.

Task* XrdFileCache::Prefetch::CreateTaskForFirstUndownloadedBlock ( )
private

Prefetch block.

void XrdFileCache::Prefetch::DecRamBlockRefCount ( int  ramIdx)

Decrease block reference count.

void XrdFileCache::Prefetch::DoTask ( Task task)
private

Read from client into in memory cache, queue ram buffer for disk write.

Task* XrdFileCache::Prefetch::GetNextTask ( )
private

Get blocks to prefetch.

Stats& XrdFileCache::Prefetch::GetStats ( )
inline

Reference to prefetch statistics.

References m_stats.

bool XrdFileCache::Prefetch::InitiateClose ( )

Initiate close. Return true if still IO active. Used in XrdPosixXrootd::Close()

const char* XrdFileCache::Prefetch::lPath ( ) const
private

Log path.

bool XrdFileCache::Prefetch::Open ( )
private

Open file handle for data file and info file on local disk.

ssize_t XrdFileCache::Prefetch::Read ( char *  buff,
off_t  offset,
size_t  size 
)
protected

Read from disk, RAM, task, or client.

bool XrdFileCache::Prefetch::ReadFromTask ( int  bIdx,
char *  buff,
long long  off,
size_t  size 
)
private

Create task from read request and wait its completed.

ssize_t XrdFileCache::Prefetch::ReadInBlocks ( char *  buff,
off_t  offset,
size_t  size 
)
private

Split read in blocks.

int XrdFileCache::Prefetch::ReadV ( const XrdOucIOVec readV,
int  n 
)
protected

Vector read from disk if block is already downloaded, else ReadV from client.

void XrdFileCache::Prefetch::Run ( )

Thread function for file prefetching.

void XrdFileCache::Prefetch::Sync ( )

Sync file cache inf o and output data with disk.

void XrdFileCache::Prefetch::WriteBlockToDisk ( int  ramIdx,
size_t  size 
)

Write block to file on disk. Called from Cache.

Friends And Related Function Documentation

friend class IOEntireFile
friend
friend class IOFileBlock
friend

Member Data Documentation

Info XrdFileCache::Prefetch::m_cfi
private

download status of file blocks and access statistics

XrdSysMutex XrdFileCache::Prefetch::m_downloadStatusMutex
private

mutex locking access to m_cfi object

bool XrdFileCache::Prefetch::m_failed
private

reading from original source or writing to disk has failed

long long XrdFileCache::Prefetch::m_fileSize
private

size of disk file for block-based operation

bool XrdFileCache::Prefetch::m_in_sync
private
XrdOssDF* XrdFileCache::Prefetch::m_infoFile
private

file handle for data-info file on disk

XrdOucCacheIO& XrdFileCache::Prefetch::m_input
private

original data source

int XrdFileCache::Prefetch::m_non_flushed_cnt
private
long long XrdFileCache::Prefetch::m_offset
private

offset of disk file for block-based operation

XrdOssDF* XrdFileCache::Prefetch::m_output
private

file handle for data file on disk

XrdSysCondVar XrdFileCache::Prefetch::m_queueCond
private

m_tasks_queue condition variable

RAM XrdFileCache::Prefetch::m_ram
private

in memory cache

bool XrdFileCache::Prefetch::m_started
private

state of run thread

XrdSysCondVar XrdFileCache::Prefetch::m_stateCond
private

state condition variable

Stats XrdFileCache::Prefetch::m_stats
private

cache statistics, used in IO detach

Referenced by GetStats().

bool XrdFileCache::Prefetch::m_stopped
private

prefetch is stopped

bool XrdFileCache::Prefetch::m_stopping
private

run thread should be stopped

XrdJob* XrdFileCache::Prefetch::m_syncer
private
XrdSysMutex XrdFileCache::Prefetch::m_syncStatusMutex
private

mutex locking fsync status

std::deque<Task*> XrdFileCache::Prefetch::m_tasks_queue
private

download queue

std::string XrdFileCache::Prefetch::m_temp_filename
private

filename of data file on disk

std::vector<int> XrdFileCache::Prefetch::m_writes_during_sync
private

The documentation for this class was generated from the following file: