xrootd
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
XrdFileCache::Cache Class Reference

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

#include <XrdFileCache.hh>

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

Classes

struct  WriteQ
 

Public Member Functions

 Cache (XrdSysLogger *logger)
 Constructor. More...
 
virtual XrdOucCacheIO2Attach (XrdOucCacheIO2 *, int Options=0)
 
virtual int isAttached ()
 Number of cache-io objects atteched through this cache. More...
 
virtual void EnvInfo (XrdOucEnv &theEnv)
 
virtual int LocalFilePath (const char *url, char *buff=0, int blen=0, LFP_Reason why=ForAccess)
 
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 XrdFileCache configuration. More...
 
bool Config (const char *config_filename, const char *parameters)
 Parse configuration file. More...
 
void Purge ()
 Thread function running disk cache purge periodically. More...
 
int UnlinkUnlessOpen (const std::string &f_name)
 Remove file from cache unless it is currently open. 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...
 
bool RequestRAMBlock ()
 
void RAMBlockReleased ()
 
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 ()
 
void ExecuteCommandUrl (const std::string &command_url)
 
virtual XrdOucCacheIO2Attach (XrdOucCacheIO2 *ioP, int opts=0)=0
 Obtain a new IO object that fronts existing XrdOucCacheIO. More...
 
virtual XrdOucCacheIOAttach (XrdOucCacheIO *ioP, int opts=0)
 Obtain a new IO object that fronts existing XrdOucCacheIO. More...
 
- Public Member Functions inherited from XrdOucCache2
virtual XrdOucCacheIOAttach (XrdOucCacheIO *ioP, int opts=0)
 
virtual XrdOucCacheCreate (Parms &Params, XrdOucCacheIO::aprParms *aprP=0)
 
 XrdOucCache2 ()
 
virtual ~XrdOucCache2 ()
 
virtual XrdOucCacheIOAttach (XrdOucCacheIO *ioP, int Options=0)=0
 
- Public Member Functions inherited from XrdOucCache
virtual int Rmdir (const char *)
 
virtual int Rename (const char *, const char *)
 
virtual int Truncate (const char *, off_t)
 
 XrdOucCache ()
 
virtual ~XrdOucCache ()
 

Static Public Member Functions

static CacheCreateInstance (XrdSysLogger *logger)
 Singleton creation. More...
 
static CacheGetInstance ()
 Singleton access. More...
 
static bool VCheck (XrdVersionInfo &urVersion)
 Version check. More...
 

Private Types

typedef std::map< std::string, File * > ActiveMap_t
 
typedef ActiveMap_t::iterator ActiveMap_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 xdlib (XrdOucStream &)
 
bool xtrace (XrdOucStream &)
 
bool cfg2bytes (const std::string &str, long long &store, long long totalSpace, const char *name)
 
int UnlinkCommon (const std::string &f_name, bool fail_if_open)
 
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)
 

Private Attributes

XrdSysError m_log
 XrdFileCache namespace logger. More...
 
XrdSysTracem_trace
 
const char * m_traceID
 
XrdOucCacheStats m_stats
 
XrdOssm_output_fs
 disk cache file system More...
 
std::vector< XrdFileCache::Decision * > m_decisionpoints
 decision plugins More...
 
std::map< std::string, long long > m_filesInQueue
 
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_RAMblock_mutex
 lock for allcoation of RAM blocks More...
 
int m_RAMblocks_used
 
bool m_isClient
 True if running as client. More...
 
WriteQ m_writeQ
 
ActiveMap_t m_active
 
FNameSet_t m_purge_delay_set
 
bool m_in_purge
 
XrdSysCondVar m_active_cond
 
PrefetchList m_prefetchList
 

Static Private Attributes

static Cachem_factory
 this object More...
 
static XrdSchedulerschedP
 

Additional Inherited Members

- Public Types inherited from XrdOucCache2
enum  LFP_Reason { ForAccess =0, ForInfo, ForPath }
 
- Public Attributes inherited from XrdOucCache
XrdOucCacheStats Stats
 
- Static Public Attributes inherited from XrdOucCache
static const int optADB = 0x1000
 
static const int optFIS = 0x0001
 
static const int optFIU = 0x0002
 
static const int optRW = 0x0004
 
static const int optNEW = 0x0014
 
static const int optWIN = 0x0024
 
static const int isServer = 0x0010
 
static const int isStructured = 0x0020
 
static const int canPreRead = 0x0040
 
static const int logStats = 0x0080
 
static const int Serialized = 0x0004
 
static const int ioMTSafe = 0x0008
 
static const int Debug = 0x0003
 

Detailed Description

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

Member Typedef Documentation

◆ ActiveMap_i

typedef ActiveMap_t::iterator XrdFileCache::Cache::ActiveMap_i
private

◆ ActiveMap_t

typedef std::map<std::string, File*> XrdFileCache::Cache::ActiveMap_t
private

◆ FNameSet_t

typedef std::set<std::string> XrdFileCache::Cache::FNameSet_t
private

◆ PrefetchList

typedef std::vector<File*> XrdFileCache::Cache::PrefetchList
private

Constructor & Destructor Documentation

◆ Cache()

XrdFileCache::Cache::Cache ( XrdSysLogger logger)

Constructor.

Member Function Documentation

◆ AddWriteTask()

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

Add downloaded block in write queue.

◆ Attach() [1/3]

virtual XrdOucCacheIO2* XrdOucCache2::Attach

Obtain a new IO object that fronts existing XrdOucCacheIO.

◆ Attach() [2/3]

virtual XrdOucCacheIO* XrdOucCache2::Attach
inline

Obtain a new IO object that fronts existing XrdOucCacheIO.

◆ Attach() [3/3]

virtual XrdOucCacheIO2* XrdFileCache::Cache::Attach ( XrdOucCacheIO2 ,
int  Options = 0 
)
virtual

Implements XrdOucCache2.

◆ cfg2bytes()

bool XrdFileCache::Cache::cfg2bytes ( const std::string &  str,
long long &  store,
long long  totalSpace,
const char *  name 
)
private

◆ Config()

bool XrdFileCache::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

◆ ConfigParameters()

bool XrdFileCache::Cache::ConfigParameters ( std::string  ,
XrdOucStream ,
TmpConfiguration tmpc 
)
private

◆ ConfigXeq()

bool XrdFileCache::Cache::ConfigXeq ( char *  ,
XrdOucStream  
)
private

◆ CreateInstance()

static Cache& XrdFileCache::Cache::CreateInstance ( XrdSysLogger logger)
static

Singleton creation.

◆ dec_ref_cnt()

void XrdFileCache::Cache::dec_ref_cnt ( File ,
bool  high_debug 
)
private

◆ Decide()

bool XrdFileCache::Cache::Decide ( XrdOucCacheIO )

Makes decision if the original XrdOucCacheIO should be cached.

Parameters
&URL of file
Returns
decision if IO object will be cached.

◆ DeRegisterPrefetchFile()

void XrdFileCache::Cache::DeRegisterPrefetchFile ( File )

◆ EnvInfo()

virtual void XrdFileCache::Cache::EnvInfo ( XrdOucEnv theEnv)
virtual

Supply environmental information to the cache. This is only called on the server but is optional and might not be called. When it is called, it is gauranteed to occur before any active use of the cache and is essentially serialized (i.e. the main start-up thread is used). The environmental information should only be used to optimize processing. For instance, when cache monitoring is enabled, the variable "pfc.gStream*" is defined and is a pointer to a gStream object that can be used to report statistical information to a monitoring collector.

Parameters
theEnv- Reference to environmental information.

Reimplemented from XrdOucCache2.

◆ ExecuteCommandUrl()

void XrdFileCache::Cache::ExecuteCommandUrl ( const std::string &  command_url)

◆ FileSyncDone()

void XrdFileCache::Cache::FileSyncDone ( File ,
bool  high_debug 
)

◆ GetFile()

File* XrdFileCache::Cache::GetFile ( const std::string &  ,
IO ,
long long  off = 0,
long long  filesize = 0 
)

◆ GetInstance()

static Cache& XrdFileCache::Cache::GetInstance ( )
static

Singleton access.

◆ GetLog()

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

References m_log.

◆ GetNextFileToPrefetch()

File* XrdFileCache::Cache::GetNextFileToPrefetch ( )

◆ GetOss()

XrdOss* XrdFileCache::Cache::GetOss ( ) const
inline

References m_output_fs.

◆ GetTrace()

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

References m_trace.

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

◆ inc_ref_cnt()

void XrdFileCache::Cache::inc_ref_cnt ( File ,
bool  lock,
bool  high_debug 
)
private

◆ isAttached()

virtual int XrdFileCache::Cache::isAttached ( )
virtual

Number of cache-io objects atteched through this cache.

Reimplemented from XrdOucCache.

◆ IsFileActiveOrPurgeProtected()

bool XrdFileCache::Cache::IsFileActiveOrPurgeProtected ( const std::string &  )

◆ LocalFilePath()

virtual int XrdFileCache::Cache::LocalFilePath ( const char *  url,
char *  buff = 0,
int  blen = 0,
LFP_Reason  why = ForAccess 
)
virtual

Reimplemented from XrdOucCache2.

◆ Prefetch()

void XrdFileCache::Cache::Prefetch ( )

◆ Prepare()

virtual int XrdFileCache::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. Use the XrdOucCacheIO2::Open() method to open the file at a later time.

Reimplemented from XrdOucCache2.

◆ ProcessWriteTasks()

void XrdFileCache::Cache::ProcessWriteTasks ( )

Separate task which writes blocks from ram to disk.

◆ Purge()

void XrdFileCache::Cache::Purge ( )

Thread function running disk cache purge periodically.

◆ RAMBlockReleased()

void XrdFileCache::Cache::RAMBlockReleased ( )

◆ RefConfiguration()

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

Reference XrdFileCache configuration.

References m_configuration.

◆ RegisterPrefetchFile()

void XrdFileCache::Cache::RegisterPrefetchFile ( File )

◆ ReleaseFile()

void XrdFileCache::Cache::ReleaseFile ( File ,
IO  
)

◆ RemoveWriteQEntriesFor()

void XrdFileCache::Cache::RemoveWriteQEntriesFor ( File f)

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

◆ RequestRAMBlock()

bool XrdFileCache::Cache::RequestRAMBlock ( )

◆ schedule_file_sync()

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

Referenced by ScheduleFileSync().

◆ ScheduleFileSync()

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

References schedule_file_sync().

◆ Stat()

virtual int XrdFileCache::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 XrdOucCache2.

◆ Unlink()

virtual int XrdFileCache::Cache::Unlink ( const char *  url)
virtual

Reimplemented from XrdOucCache.

◆ UnlinkCommon()

int XrdFileCache::Cache::UnlinkCommon ( const std::string &  f_name,
bool  fail_if_open 
)
private

◆ UnlinkUnlessOpen()

int XrdFileCache::Cache::UnlinkUnlessOpen ( const std::string &  f_name)

Remove file from cache unless it is currently open.

◆ VCheck()

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

Version check.

◆ xdlib()

bool XrdFileCache::Cache::xdlib ( XrdOucStream )
private

◆ xtrace()

bool XrdFileCache::Cache::xtrace ( XrdOucStream )
private

Member Data Documentation

◆ m_active

ActiveMap_t XrdFileCache::Cache::m_active
private

◆ m_active_cond

XrdSysCondVar XrdFileCache::Cache::m_active_cond
private

◆ m_configuration

Configuration XrdFileCache::Cache::m_configuration
private

configurable parameters

Referenced by RefConfiguration().

◆ m_decisionpoints

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

decision plugins

◆ m_factory

Cache* XrdFileCache::Cache::m_factory
staticprivate

this object

◆ m_filesInQueue

std::map<std::string, long long> XrdFileCache::Cache::m_filesInQueue
private

◆ m_in_purge

bool XrdFileCache::Cache::m_in_purge
private

◆ m_isClient

bool XrdFileCache::Cache::m_isClient
private

True if running as client.

◆ m_log

XrdSysError XrdFileCache::Cache::m_log
private

XrdFileCache namespace logger.

Referenced by GetLog().

◆ m_output_fs

XrdOss* XrdFileCache::Cache::m_output_fs
private

disk cache file system

Referenced by GetOss().

◆ m_prefetch_condVar

XrdSysCondVar XrdFileCache::Cache::m_prefetch_condVar
private

lock for vector of prefetching files

◆ m_prefetch_enabled

bool XrdFileCache::Cache::m_prefetch_enabled
private

set to true when prefetching is enabled

◆ m_prefetchList

PrefetchList XrdFileCache::Cache::m_prefetchList
private

◆ m_purge_delay_set

FNameSet_t XrdFileCache::Cache::m_purge_delay_set
private

◆ m_RAMblock_mutex

XrdSysMutex XrdFileCache::Cache::m_RAMblock_mutex
private

lock for allcoation of RAM blocks

◆ m_RAMblocks_used

int XrdFileCache::Cache::m_RAMblocks_used
private

◆ m_stats

XrdOucCacheStats XrdFileCache::Cache::m_stats
private

◆ m_trace

XrdSysTrace* XrdFileCache::Cache::m_trace
private

Referenced by GetTrace().

◆ m_traceID

const char* XrdFileCache::Cache::m_traceID
private

◆ m_writeQ

WriteQ XrdFileCache::Cache::m_writeQ
private

◆ schedP

XrdScheduler* XrdFileCache::Cache::schedP
staticprivate

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