xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
XrdPfc::File Class Reference

#include <XrdPfcFile.hh>

Collaboration diagram for XrdPfc::File:
Collaboration graph
[legend]

Public Member Functions

 ~File ()
 Destructor. More...
 
void BlockRemovedFromWriteQ (Block *)
 Handle removal of a block from Cache's write queue. More...
 
void BlocksRemovedFromWriteQ (std::list< Block * > &)
 Handle removal of a set of blocks from Cache's write queue. More...
 
int Read (IO *io, char *buff, long long offset, int size, ReadReqRH *rh)
 Normal read. More...
 
int ReadV (IO *io, const XrdOucIOVec *readV, int readVnum, ReadReqRH *rh)
 Vector read. More...
 
void ioUpdated (IO *io)
 Notification from IO that it has been updated (remote open). More...
 
bool ioActive (IO *io)
 Initiate close. Return true if still IO active. Used in XrdPosixXrootd::Close() More...
 
void RequestSyncOfDetachStats ()
 Flags that detach stats should be written out in final sync. Called from CacheIO upon Detach. More...
 
bool FinalizeSyncBeforeExit ()
 Returns true if any of blocks need sync. Called from Cache::dec_ref_cnt on zero ref cnt. More...
 
void Sync ()
 Sync file cache inf o and output data with disk. More...
 
void WriteBlockToDisk (Block *b)
 
void Prefetch ()
 
float GetPrefetchScore () const
 
const char * lPath () const
 Log path. More...
 
std::string & GetLocalPath ()
 
XrdSysErrorGetLog ()
 
XrdSysTraceGetTrace ()
 
long long GetFileSize ()
 
void AddIO (IO *io)
 
int GetPrefetchCountOnIO (IO *io)
 
void StopPrefetchingOnIO (IO *io)
 
void RemoveIO (IO *io)
 
Stats DeltaStatsFromLastCall ()
 
std::string GetRemoteLocations () const
 
const Info::AStatGetLastAccessStats () const
 
size_t GetAccessCnt () const
 
int GetBlockSize () const
 
int GetNBlocks () const
 
int GetNDownloadedBlocks () const
 
const StatsRefStats () const
 
int get_ref_cnt ()
 
int inc_ref_cnt ()
 
int dec_ref_cnt ()
 
void initiate_emergency_shutdown ()
 
bool is_in_emergency_shutdown ()
 

Static Public Member Functions

static FileFileOpen (const std::string &path, long long offset, long long fileSize)
 Static constructor that also does Open. Returns null ptr if Open fails. More...
 

Private Types

enum  PrefetchState_e {
  kOff =-1, kOn, kHold, kStopped,
  kComplete
}
 
typedef std::set< IO * > IoSet_t
 
typedef IoSet_t::iterator IoSet_i
 
typedef std::list< int > IntList_t
 
typedef IntList_t::iterator IntList_i
 
typedef std::map< int, Block * > BlockMap_t
 
typedef BlockMap_t::iterator BlockMap_i
 

Private Member Functions

 File (const std::string &path, long long offset, long long fileSize)
 Constructor. More...
 
bool Open ()
 Open file handle for data file and info file on local disk. More...
 
void insert_remote_location (const std::string &loc)
 
void inc_prefetch_read_cnt (int prc)
 
void inc_prefetch_hit_cnt (int phc)
 
void calc_prefetch_score ()
 
bool overlap (int blk, long long blk_size, long long req_off, int req_size, long long &off, long long &blk_off, int &size)
 
BlockPrepareBlockRequest (int i, IO *io, void *req_id, bool prefetch)
 
void ProcessBlockRequest (Block *b)
 
void ProcessBlockRequests (BlockList_t &blks)
 
void RequestBlocksDirect (IO *io, DirectResponseHandler *handler, std::vector< XrdOucIOVec > &ioVec, int expected_size)
 
int ReadBlocksFromDisk (std::vector< XrdOucIOVec > &ioVec, int expected_size)
 
int ReadOpusCoalescere (IO *io, const XrdOucIOVec *readV, int readVnum, ReadReqRH *rh, const char *tpfx)
 
void ProcessDirectReadFinished (ReadRequest *rreq, int bytes_read, int error_cond)
 
void ProcessBlockError (Block *b, ReadRequest *rreq)
 
void ProcessBlockSuccess (Block *b, ChunkRequest &creq)
 
void FinalizeReadRequest (ReadRequest *rreq)
 
void ProcessBlockResponse (Block *b, int res)
 
void inc_ref_count (Block *b)
 
void dec_ref_count (Block *b, int count=1)
 
void free_block (Block *)
 
bool select_current_io_or_disable_prefetching (bool skip_current)
 
int offsetIdx (int idx) const
 

Private Attributes

int m_ref_cnt
 number of references from IO or sync More...
 
XrdOssDFm_data_file
 file handle for data file on disk More...
 
XrdOssDFm_info_file
 file handle for data-info file on disk More...
 
Info m_cfi
 download status of file blocks and access statistics More...
 
std::string m_filename
 filename of data file on disk More...
 
long long m_offset
 offset of cached file for block-based / hdfs operation More...
 
long long m_file_size
 size of cached disk file for block-based operation More...
 
IoSet_t m_io_set
 
IoSet_i m_current_io
 IO object to be used for prefetching. More...
 
int m_ios_in_detach
 Number of IO objects to which we replied false to ioActive() and will be removed soon. More...
 
std::vector< int > m_writes_during_sync
 
int m_non_flushed_cnt
 
bool m_in_sync
 
bool m_detach_time_logged
 
bool m_in_shutdown
 file is in emergency shutdown due to irrecoverable error or unlink request More...
 
BlockMap_t m_block_map
 
XrdSysCondVar m_state_cond
 
long long m_block_size
 
int m_num_blocks
 
Stats m_stats
 cache statistics for this instance More...
 
Stats m_last_stats
 copy of cache stats during last purge cycle, used for per directory stat reporting More...
 
std::set< std::string > m_remote_locations
 Gathered in AddIO / ioUpdate / ioActive. More...
 
PrefetchState_e m_prefetch_state
 
int m_prefetch_read_cnt
 
int m_prefetch_hit_cnt
 
float m_prefetch_score
 

Static Private Attributes

static const char * m_traceID
 

Friends

class BlockResponseHandler
 
class DirectResponseHandler
 

Member Typedef Documentation

typedef BlockMap_t::iterator XrdPfc::File::BlockMap_i
private
typedef std::map<int, Block*> XrdPfc::File::BlockMap_t
private
typedef IntList_t::iterator XrdPfc::File::IntList_i
private
typedef std::list<int> XrdPfc::File::IntList_t
private
typedef IoSet_t::iterator XrdPfc::File::IoSet_i
private
typedef std::set<IO*> XrdPfc::File::IoSet_t
private

Member Enumeration Documentation

Enumerator
kOff 
kOn 
kHold 
kStopped 
kComplete 

Constructor & Destructor Documentation

XrdPfc::File::~File ( )

Destructor.

XrdPfc::File::File ( const std::string &  path,
long long  offset,
long long  fileSize 
)
private

Constructor.

Member Function Documentation

void XrdPfc::File::AddIO ( IO io)
void XrdPfc::File::BlockRemovedFromWriteQ ( Block )

Handle removal of a block from Cache's write queue.

void XrdPfc::File::BlocksRemovedFromWriteQ ( std::list< Block * > &  )

Handle removal of a set of blocks from Cache's write queue.

void XrdPfc::File::calc_prefetch_score ( )
inlineprivate
int XrdPfc::File::dec_ref_cnt ( )
inline

References m_ref_cnt.

void XrdPfc::File::dec_ref_count ( Block b,
int  count = 1 
)
inlineprivate
Stats XrdPfc::File::DeltaStatsFromLastCall ( )
static File* XrdPfc::File::FileOpen ( const std::string &  path,
long long  offset,
long long  fileSize 
)
static

Static constructor that also does Open. Returns null ptr if Open fails.

void XrdPfc::File::FinalizeReadRequest ( ReadRequest rreq)
private
bool XrdPfc::File::FinalizeSyncBeforeExit ( )

Returns true if any of blocks need sync. Called from Cache::dec_ref_cnt on zero ref cnt.

void XrdPfc::File::free_block ( Block )
private

Referenced by dec_ref_count().

int XrdPfc::File::get_ref_cnt ( )
inline

References m_ref_cnt.

size_t XrdPfc::File::GetAccessCnt ( ) const
inline
int XrdPfc::File::GetBlockSize ( ) const
inline
long long XrdPfc::File::GetFileSize ( )
inline

References m_file_size.

const Info::AStat* XrdPfc::File::GetLastAccessStats ( ) const
inline
std::string& XrdPfc::File::GetLocalPath ( )
inline

References m_filename.

XrdSysError* XrdPfc::File::GetLog ( )
int XrdPfc::File::GetNBlocks ( ) const
inline
int XrdPfc::File::GetNDownloadedBlocks ( ) const
inline
int XrdPfc::File::GetPrefetchCountOnIO ( IO io)
float XrdPfc::File::GetPrefetchScore ( ) const
std::string XrdPfc::File::GetRemoteLocations ( ) const
XrdSysTrace* XrdPfc::File::GetTrace ( )
void XrdPfc::File::inc_prefetch_hit_cnt ( int  phc)
inlineprivate
void XrdPfc::File::inc_prefetch_read_cnt ( int  prc)
inlineprivate
int XrdPfc::File::inc_ref_cnt ( )
inline

References m_ref_cnt.

void XrdPfc::File::inc_ref_count ( Block b)
inlineprivate
void XrdPfc::File::initiate_emergency_shutdown ( )
void XrdPfc::File::insert_remote_location ( const std::string &  loc)
private
bool XrdPfc::File::ioActive ( IO io)

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

void XrdPfc::File::ioUpdated ( IO io)

Notification from IO that it has been updated (remote open).

bool XrdPfc::File::is_in_emergency_shutdown ( )
inline

References m_in_shutdown.

const char* XrdPfc::File::lPath ( ) const

Log path.

int XrdPfc::File::offsetIdx ( int  idx) const
private
bool XrdPfc::File::Open ( )
private

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

bool XrdPfc::File::overlap ( int  blk,
long long  blk_size,
long long  req_off,
int  req_size,
long long &  off,
long long &  blk_off,
int &  size 
)
private
void XrdPfc::File::Prefetch ( )
Block* XrdPfc::File::PrepareBlockRequest ( int  i,
IO io,
void *  req_id,
bool  prefetch 
)
private
void XrdPfc::File::ProcessBlockError ( Block b,
ReadRequest rreq 
)
private
void XrdPfc::File::ProcessBlockRequest ( Block b)
private
void XrdPfc::File::ProcessBlockRequests ( BlockList_t blks)
private
void XrdPfc::File::ProcessBlockResponse ( Block b,
int  res 
)
private
void XrdPfc::File::ProcessBlockSuccess ( Block b,
ChunkRequest creq 
)
private
void XrdPfc::File::ProcessDirectReadFinished ( ReadRequest rreq,
int  bytes_read,
int  error_cond 
)
private
int XrdPfc::File::Read ( IO io,
char *  buff,
long long  offset,
int  size,
ReadReqRH rh 
)

Normal read.

int XrdPfc::File::ReadBlocksFromDisk ( std::vector< XrdOucIOVec > &  ioVec,
int  expected_size 
)
private
int XrdPfc::File::ReadOpusCoalescere ( IO io,
const XrdOucIOVec readV,
int  readVnum,
ReadReqRH rh,
const char *  tpfx 
)
private
int XrdPfc::File::ReadV ( IO io,
const XrdOucIOVec readV,
int  readVnum,
ReadReqRH rh 
)

Vector read.

const Stats& XrdPfc::File::RefStats ( ) const
inline

References m_stats.

void XrdPfc::File::RemoveIO ( IO io)
void XrdPfc::File::RequestBlocksDirect ( IO io,
DirectResponseHandler handler,
std::vector< XrdOucIOVec > &  ioVec,
int  expected_size 
)
private
void XrdPfc::File::RequestSyncOfDetachStats ( )

Flags that detach stats should be written out in final sync. Called from CacheIO upon Detach.

bool XrdPfc::File::select_current_io_or_disable_prefetching ( bool  skip_current)
private
void XrdPfc::File::StopPrefetchingOnIO ( IO io)
void XrdPfc::File::Sync ( )

Sync file cache inf o and output data with disk.

void XrdPfc::File::WriteBlockToDisk ( Block b)

Friends And Related Function Documentation

friend class BlockResponseHandler
friend
friend class DirectResponseHandler
friend

Member Data Documentation

BlockMap_t XrdPfc::File::m_block_map
private
long long XrdPfc::File::m_block_size
private
Info XrdPfc::File::m_cfi
private

download status of file blocks and access statistics

Referenced by GetAccessCnt(), GetBlockSize(), GetLastAccessStats(), GetNBlocks(), and GetNDownloadedBlocks().

IoSet_i XrdPfc::File::m_current_io
private

IO object to be used for prefetching.

XrdOssDF* XrdPfc::File::m_data_file
private

file handle for data file on disk

bool XrdPfc::File::m_detach_time_logged
private
long long XrdPfc::File::m_file_size
private

size of cached disk file for block-based operation

Referenced by GetFileSize().

std::string XrdPfc::File::m_filename
private

filename of data file on disk

Referenced by GetLocalPath().

bool XrdPfc::File::m_in_shutdown
private

file is in emergency shutdown due to irrecoverable error or unlink request

Referenced by is_in_emergency_shutdown().

bool XrdPfc::File::m_in_sync
private
XrdOssDF* XrdPfc::File::m_info_file
private

file handle for data-info file on disk

IoSet_t XrdPfc::File::m_io_set
private
int XrdPfc::File::m_ios_in_detach
private

Number of IO objects to which we replied false to ioActive() and will be removed soon.

Stats XrdPfc::File::m_last_stats
private

copy of cache stats during last purge cycle, used for per directory stat reporting

int XrdPfc::File::m_non_flushed_cnt
private
int XrdPfc::File::m_num_blocks
private
long long XrdPfc::File::m_offset
private

offset of cached file for block-based / hdfs operation

int XrdPfc::File::m_prefetch_hit_cnt
private
int XrdPfc::File::m_prefetch_read_cnt
private
float XrdPfc::File::m_prefetch_score
private

Referenced by calc_prefetch_score().

PrefetchState_e XrdPfc::File::m_prefetch_state
private
int XrdPfc::File::m_ref_cnt
private

number of references from IO or sync

Referenced by dec_ref_cnt(), get_ref_cnt(), and inc_ref_cnt().

std::set<std::string> XrdPfc::File::m_remote_locations
private

Gathered in AddIO / ioUpdate / ioActive.

XrdSysCondVar XrdPfc::File::m_state_cond
private
Stats XrdPfc::File::m_stats
private

cache statistics for this instance

Referenced by RefStats().

const char* XrdPfc::File::m_traceID
staticprivate
std::vector<int> XrdPfc::File::m_writes_during_sync
private

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