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

Attaches/creates and detaches/deletes cache-io objects for disk based cache. More...

#include <XrdPfc.hh>

Inheritance diagram for XrdPfc::Cache:
Inheritance graph
[legend]
Collaboration diagram for XrdPfc::Cache:
Collaboration graph
[legend]

Classes

struct  WriteQ
 

Public Member Functions

 Cache (XrdSysLogger *logger, XrdOucEnv *env)
 Constructor. More...
 
virtual XrdOucCacheIOAttach (XrdOucCacheIO *, int Options=0)
 
virtual int LocalFilePath (const char *url, char *buff=0, int blen=0, LFP_Reason why=ForAccess, bool forall=false)
 
virtual int Prepare (const char *url, int oflags, mode_t mode)
 
virtual int Stat (const char *url, struct stat &sbuff)
 
virtual int Unlink (const char *url)
 
bool Decide (XrdOucCacheIO *)
 Makes decision if the original XrdOucCacheIO should be cached. More...
 
const ConfigurationRefConfiguration () const
 Reference XrdPfc configuration. More...
 
bool Config (const char *config_filename, const char *parameters)
 Parse configuration file. More...
 
void ResourceMonitorHeartBeat ()
 Thread function checking resource usage periodically. More...
 
void Purge ()
 Thread function invoked to scan and purge files from disk when needed. More...
 
int UnlinkFile (const std::string &f_name, bool fail_if_open)
 Remove cinfo and data files from cache. More...
 
void AddWriteTask (Block *b, bool from_read)
 Add downloaded block in write queue. More...
 
void RemoveWriteQEntriesFor (File *f)
 Remove blocks from write queue which belong to given prefetch. This method is used at the time of File destruction. More...
 
void ProcessWriteTasks ()
 Separate task which writes blocks from ram to disk. More...
 
char * RequestRAM (long long size)
 
void ReleaseRAM (char *buf, long long size)
 
void RegisterPrefetchFile (File *)
 
void DeRegisterPrefetchFile (File *)
 
FileGetNextFileToPrefetch ()
 
void Prefetch ()
 
XrdOssGetOss () const
 
bool IsFileActiveOrPurgeProtected (const std::string &)
 
FileGetFile (const std::string &, IO *, long long off=0, long long filesize=0)
 
void ReleaseFile (File *, IO *)
 
void ScheduleFileSync (File *f)
 
void FileSyncDone (File *, bool high_debug)
 
XrdSysErrorGetLog ()
 
XrdSysTraceGetTrace ()
 
XrdXrootdGStreamGetGStream ()
 
void ExecuteCommandUrl (const std::string &command_url)
 
- Public Member Functions inherited from XrdOucCache
virtual int Rename (const char *oldp, const char *newp)
 
virtual int Rmdir (const char *dirp)
 
virtual int Truncate (const char *path, off_t size)
 
virtual int Xeq (XeqCmd cmd, char *arg, int arglen)
 
 XrdOucCache (const char *ctype)
 
virtual ~XrdOucCache ()
 Destructor. More...
 

Static Public Member Functions

static CacheCreateInstance (XrdSysLogger *logger, XrdOucEnv *env)
 Singleton creation. More...
 
static CacheGetInstance ()
 Singleton access. More...
 
static const CacheTheOne ()
 
static const ConfigurationConf ()
 
static bool VCheck (XrdVersionInfo &urVersion)
 Version check. More...
 

Static Public Attributes

static XrdSchedulerschedP
 
- Static Public Attributes inherited from XrdOucCache
static const int optFIS = 0x0001
 File is structured (e.g. root file) More...
 
static const int optRW = 0x0004
 File is read/write (o/w read/only) More...
 
static const int optNEW = 0x0014
 File is new -> optRW (o/w read or write) More...
 
static const int optWIN = 0x0024
 File is new -> optRW use write-in cache. More...
 

Private Types

enum  ScanAndPurgeThreadState_e { SPTS_Idle, SPTS_Scan, SPTS_Purge, SPTS_Done }
 
typedef std::map< std::string,
File * > 
ActiveMap_t
 
typedef ActiveMap_t::iterator ActiveMap_i
 
typedef std::multimap
< std::string, XrdPfc::Stats
StatsMMap_t
 
typedef StatsMMap_t::iterator StatsMMap_i
 
typedef std::set< std::string > FNameSet_t
 
typedef std::vector< File * > PrefetchList
 

Private Member Functions

bool ConfigParameters (std::string, XrdOucStream &, TmpConfiguration &tmpc)
 
bool ConfigXeq (char *, XrdOucStream &)
 
bool xcschk (XrdOucStream &)
 
bool xdlib (XrdOucStream &)
 
bool xtrace (XrdOucStream &)
 
bool cfg2bytes (const std::string &str, long long &store, long long totalSpace, const char *name)
 
void inc_ref_cnt (File *, bool lock, bool high_debug)
 
void dec_ref_cnt (File *, bool high_debug)
 
void schedule_file_sync (File *, bool ref_cnt_already_set, bool high_debug)
 
void copy_out_active_stats_and_update_data_fs_state ()
 

Private Attributes

XrdOucEnvm_env
 environment passed in at creation More...
 
XrdSysError m_log
 XrdPfc namespace logger. More...
 
XrdSysTracem_trace
 
const char * m_traceID
 
XrdOssm_oss
 disk cache file system More...
 
XrdXrootdGStreamm_gstream
 
std::vector< XrdPfc::Decision * > m_decisionpoints
 decision plugins More...
 
Configuration m_configuration
 configurable parameters More...
 
XrdSysCondVar m_prefetch_condVar
 lock for vector of prefetching files More...
 
bool m_prefetch_enabled
 set to true when prefetching is enabled More...
 
XrdSysMutex m_RAM_mutex
 lock for allcoation of RAM blocks More...
 
long long m_RAM_used
 
long long m_RAM_write_queue
 
std::list< char * > m_RAM_std_blocks
 A list of blocks of standard size, to be reused. More...
 
int m_RAM_std_size
 
bool m_isClient
 True if running as client. More...
 
WriteQ m_writeQ
 
ActiveMap_t m_active
 Map of currently active / open files. More...
 
StatsMMap_t m_closed_files_stats
 
FNameSet_t m_purge_delay_set
 
bool m_in_purge
 
XrdSysCondVar m_active_cond
 Cond-var protecting active file data structures. More...
 
PrefetchList m_prefetchList
 
XrdSysCondVar m_stats_n_purge_cond
 communication between heart-beat and scan-purge threads More...
 
DataFsState * m_fs_state
 directory state for access / usage info and quotas More...
 
int m_last_scan_duration
 
int m_last_purge_duration
 
ScanAndPurgeThreadState_e m_spt_state
 

Static Private Attributes

static Cachem_instance
 this object More...
 

Additional Inherited Members

- Public Types inherited from XrdOucCache
enum  LFP_Reason { ForAccess =0, ForInfo, ForPath }
 
enum  XeqCmd { xeqNoop = 0 }
 
- Public Attributes inherited from XrdOucCache
XrdOucCacheStats Statistics
 
const char CacheType [8]
 A 1-to-7 character cache type identifier (usually pfc or rmc). More...
 

Detailed Description

Attaches/creates and detaches/deletes cache-io objects for disk based cache.

Member Typedef Documentation

typedef ActiveMap_t::iterator XrdPfc::Cache::ActiveMap_i
private
typedef std::map<std::string, File*> XrdPfc::Cache::ActiveMap_t
private
typedef std::set<std::string> XrdPfc::Cache::FNameSet_t
private
typedef std::vector<File*> XrdPfc::Cache::PrefetchList
private
typedef StatsMMap_t::iterator XrdPfc::Cache::StatsMMap_i
private
typedef std::multimap<std::string, XrdPfc::Stats> XrdPfc::Cache::StatsMMap_t
private

Member Enumeration Documentation

Enumerator
SPTS_Idle 
SPTS_Scan 
SPTS_Purge 
SPTS_Done 

Constructor & Destructor Documentation

XrdPfc::Cache::Cache ( XrdSysLogger logger,
XrdOucEnv env 
)

Constructor.

Member Function Documentation

void XrdPfc::Cache::AddWriteTask ( Block b,
bool  from_read 
)

Add downloaded block in write queue.

virtual XrdOucCacheIO* XrdPfc::Cache::Attach ( XrdOucCacheIO ,
int  Options = 0 
)
virtual

Implements XrdOucCache.

bool XrdPfc::Cache::cfg2bytes ( const std::string &  str,
long long &  store,
long long  totalSpace,
const char *  name 
)
private
static const Configuration& XrdPfc::Cache::Conf ( )
static
bool XrdPfc::Cache::Config ( const char *  config_filename,
const char *  parameters 
)

Parse configuration file.

Parameters
config_filenamepath to configuration file
parametersoptional parameters to be passed
Returns
parse status
bool XrdPfc::Cache::ConfigParameters ( std::string  ,
XrdOucStream ,
TmpConfiguration tmpc 
)
private
bool XrdPfc::Cache::ConfigXeq ( char *  ,
XrdOucStream  
)
private
void XrdPfc::Cache::copy_out_active_stats_and_update_data_fs_state ( )
private
static Cache& XrdPfc::Cache::CreateInstance ( XrdSysLogger logger,
XrdOucEnv env 
)
static

Singleton creation.

void XrdPfc::Cache::dec_ref_cnt ( File ,
bool  high_debug 
)
private
bool XrdPfc::Cache::Decide ( XrdOucCacheIO )

Makes decision if the original XrdOucCacheIO should be cached.

Parameters
&URL of file
Returns
decision if IO object will be cached.
void XrdPfc::Cache::DeRegisterPrefetchFile ( File )
void XrdPfc::Cache::ExecuteCommandUrl ( const std::string &  command_url)
void XrdPfc::Cache::FileSyncDone ( File ,
bool  high_debug 
)
File* XrdPfc::Cache::GetFile ( const std::string &  ,
IO ,
long long  off = 0,
long long  filesize = 0 
)
XrdXrootdGStream* XrdPfc::Cache::GetGStream ( )
inline

References m_gstream.

static Cache& XrdPfc::Cache::GetInstance ( )
static

Singleton access.

XrdSysError* XrdPfc::Cache::GetLog ( )
inline

References m_log.

File* XrdPfc::Cache::GetNextFileToPrefetch ( )
XrdOss* XrdPfc::Cache::GetOss ( ) const
inline

References m_oss.

XrdSysTrace* XrdPfc::Cache::GetTrace ( )
inline

References m_trace.

Referenced by XrdPfc::IO::GetTrace().

void XrdPfc::Cache::inc_ref_cnt ( File ,
bool  lock,
bool  high_debug 
)
private
bool XrdPfc::Cache::IsFileActiveOrPurgeProtected ( const std::string &  )
virtual int XrdPfc::Cache::LocalFilePath ( const char *  url,
char *  buff = 0,
int  blen = 0,
LFP_Reason  why = ForAccess,
bool  forall = false 
)
virtual

Reimplemented from XrdOucCache.

void XrdPfc::Cache::Prefetch ( )
virtual int XrdPfc::Cache::Prepare ( const char *  url,
int  oflags,
mode_t  mode 
)
virtual

Prepare the cache for a file open request. This method is called prior to actually opening a file. This method is meant to allow defering an open request or implementing the full I/O stack in the cache layer.

Parameters
url- Pointer to the url about to be opened.
oflags- Standard Unix open flags (see open(2)).
mode- Standard mode flags if file is being created.
Returns
<0 Error has occurred, return value is -errno; fail open request. The error code -EUSERS may be returned to trigger overload recovery as specified by the xrootd.fsoverload directive. No other method should return this error code. =0 Continue with open() request. >0 Defer open but treat the file as actually being open.

Reimplemented from XrdOucCache.

void XrdPfc::Cache::ProcessWriteTasks ( )

Separate task which writes blocks from ram to disk.

void XrdPfc::Cache::Purge ( )

Thread function invoked to scan and purge files from disk when needed.

const Configuration& XrdPfc::Cache::RefConfiguration ( ) const
inline

Reference XrdPfc configuration.

References m_configuration.

void XrdPfc::Cache::RegisterPrefetchFile ( File )
void XrdPfc::Cache::ReleaseFile ( File ,
IO  
)
void XrdPfc::Cache::ReleaseRAM ( char *  buf,
long long  size 
)
void XrdPfc::Cache::RemoveWriteQEntriesFor ( File f)

Remove blocks from write queue which belong to given prefetch. This method is used at the time of File destruction.

char* XrdPfc::Cache::RequestRAM ( long long  size)
void XrdPfc::Cache::ResourceMonitorHeartBeat ( )

Thread function checking resource usage periodically.

void XrdPfc::Cache::schedule_file_sync ( File ,
bool  ref_cnt_already_set,
bool  high_debug 
)
private

Referenced by ScheduleFileSync().

void XrdPfc::Cache::ScheduleFileSync ( File f)
inline

References schedule_file_sync().

virtual int XrdPfc::Cache::Stat ( const char *  url,
struct stat sbuff 
)
virtual

Perform a stat() operation (defaults to passthrough).

Parameters
urlpointer to the url whose stat information is wanted.
sbuffreference to the stat buffer to be filled in. Only fields st_size, st_blocks, st_mtime (st_atime and st_ctime may be set to st_mtime), st_ino, and st_mode need to be set. All other fields are preset and should not be changed.
Returns
<0 - Stat failed, value is -errno. =0 - Stat succeeded, sbuff holds stat information. >0 - Stat could not be done, forward operation to next level.

Reimplemented from XrdOucCache.

static const Cache& XrdPfc::Cache::TheOne ( )
static
virtual int XrdPfc::Cache::Unlink ( const char *  path)
virtual

Remove a file from the cache.

Parameters
path- the path of the file to be removed.
Returns
Success: 0
Failure: -errno

Reimplemented from XrdOucCache.

int XrdPfc::Cache::UnlinkFile ( const std::string &  f_name,
bool  fail_if_open 
)

Remove cinfo and data files from cache.

static bool XrdPfc::Cache::VCheck ( XrdVersionInfo &  urVersion)
inlinestatic

Version check.

bool XrdPfc::Cache::xcschk ( XrdOucStream )
private
bool XrdPfc::Cache::xdlib ( XrdOucStream )
private
bool XrdPfc::Cache::xtrace ( XrdOucStream )
private

Member Data Documentation

ActiveMap_t XrdPfc::Cache::m_active
private

Map of currently active / open files.

XrdSysCondVar XrdPfc::Cache::m_active_cond
private

Cond-var protecting active file data structures.

StatsMMap_t XrdPfc::Cache::m_closed_files_stats
private
Configuration XrdPfc::Cache::m_configuration
private

configurable parameters

Referenced by RefConfiguration().

std::vector<XrdPfc::Decision*> XrdPfc::Cache::m_decisionpoints
private

decision plugins

XrdOucEnv* XrdPfc::Cache::m_env
private

environment passed in at creation

DataFsState* XrdPfc::Cache::m_fs_state
private

directory state for access / usage info and quotas

XrdXrootdGStream* XrdPfc::Cache::m_gstream
private

Referenced by GetGStream().

bool XrdPfc::Cache::m_in_purge
private
Cache* XrdPfc::Cache::m_instance
staticprivate

this object

bool XrdPfc::Cache::m_isClient
private

True if running as client.

int XrdPfc::Cache::m_last_purge_duration
private
int XrdPfc::Cache::m_last_scan_duration
private
XrdSysError XrdPfc::Cache::m_log
private

XrdPfc namespace logger.

Referenced by GetLog().

XrdOss* XrdPfc::Cache::m_oss
private

disk cache file system

Referenced by GetOss().

XrdSysCondVar XrdPfc::Cache::m_prefetch_condVar
private

lock for vector of prefetching files

bool XrdPfc::Cache::m_prefetch_enabled
private

set to true when prefetching is enabled

PrefetchList XrdPfc::Cache::m_prefetchList
private
FNameSet_t XrdPfc::Cache::m_purge_delay_set
private
XrdSysMutex XrdPfc::Cache::m_RAM_mutex
private

lock for allcoation of RAM blocks

std::list<char*> XrdPfc::Cache::m_RAM_std_blocks
private

A list of blocks of standard size, to be reused.

int XrdPfc::Cache::m_RAM_std_size
private
long long XrdPfc::Cache::m_RAM_used
private
long long XrdPfc::Cache::m_RAM_write_queue
private
ScanAndPurgeThreadState_e XrdPfc::Cache::m_spt_state
private
XrdSysCondVar XrdPfc::Cache::m_stats_n_purge_cond
private

communication between heart-beat and scan-purge threads

XrdSysTrace* XrdPfc::Cache::m_trace
private

Referenced by GetTrace().

const char* XrdPfc::Cache::m_traceID
private
WriteQ XrdPfc::Cache::m_writeQ
private
XrdScheduler* XrdPfc::Cache::schedP
static

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