1 #ifndef __XRDPFC_CACHE_HH__
2 #define __XRDPFC_CACHE_HH__
26 #include "XrdVersion.hh"
180 virtual int LocalFilePath(
const char *url,
char *buff=0,
int blen=0,
185 virtual int Prepare(
const char *url,
int oflags, mode_t mode);
188 virtual int Stat(
const char *url,
struct stat &sbuff);
191 virtual int Unlink(
const char *url);
226 bool Config(
const char *config_filename,
const char *parameters,
XrdOucEnv *env);
245 static bool VCheck(XrdVersionInfo &urVersion) {
return true; }
250 int UnlinkFile(
const std::string& f_name,
bool fail_if_open);
286 File*
GetFile(
const std::string&,
IO*,
long long off = 0,
long long filesize = 0);
304 bool blocksize_str2value(
const char *from,
const char *str,
long long &val,
long long min,
long long max)
const;
305 bool prefetch_str2value(
const char *from,
const char *str,
int &val,
int min,
int max)
const;
316 bool test_oss_basics_and_features();
318 bool cfg2bytes(
const std::string &str,
long long &store,
long long totalSpace,
const char *name)
const;
320 static Cache *m_instance;
325 const char *m_traceID;
333 std::vector<Decision*> m_decisionpoints;
339 bool m_prefetch_enabled;
342 long long m_RAM_used;
343 long long m_RAM_write_queue;
344 std::list<char*> m_RAM_std_blocks;
348 bool m_dataXattr =
false;
349 bool m_metaXattr =
false;
353 WriteQ() : condVar(0), writes_between_purges(0), size(0) {}
356 std::list<Block*> queue;
357 long long writes_between_purges;
364 typedef std::map<std::string, File*> ActiveMap_t;
365 typedef ActiveMap_t::iterator ActiveMap_i;
366 typedef std::set<std::string> FNameSet_t;
368 ActiveMap_t m_active;
369 FNameSet_t m_purge_delay_set;
372 void inc_ref_cnt(
File*,
bool lock,
bool high_debug);
373 void dec_ref_cnt(
File*,
bool high_debug);
375 void schedule_file_sync(
File*,
bool ref_cnt_already_set,
bool high_debug);
378 typedef std::vector<File*> PrefetchList;
379 PrefetchList m_prefetchList;
virtual XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int opts=0)=0
Attaches/creates and detaches/deletes cache-io objects for disk based cache.
PurgePin * GetPurgePin() const
long long DetermineFullFileSize(const std::string &cinfo_fname)
void FileSyncDone(File *, bool high_debug)
File * GetFile(const std::string &, IO *, long long off=0, long long filesize=0)
static const Configuration & Conf()
bool blocksize_str2value(const char *from, const char *str, long long &val, long long min, long long max) const
virtual int LocalFilePath(const char *url, char *buff=0, int blen=0, LFP_Reason why=ForAccess, bool forall=false)
virtual int Stat(const char *url, struct stat &sbuff)
const Configuration & RefConfiguration() const
Reference XrdPfc configuration.
static ResourceMonitor & ResMon()
XrdXrootdGStream * GetGStream()
bool IsFileActiveOrPurgeProtected(const std::string &) const
void ClearPurgeProtectedSet()
void ReleaseRAM(char *buf, long long size)
virtual int ConsiderCached(const char *url)
static Cache & GetInstance()
Singleton access.
bool Config(const char *config_filename, const char *parameters, XrdOucEnv *env)
Parse configuration file.
void DeRegisterPrefetchFile(File *)
void ExecuteCommandUrl(const std::string &command_url)
void RegisterPrefetchFile(File *)
void WriteFileSizeXAttr(int cinfo_fd, long long file_size)
void ReleaseFile(File *, IO *)
void AddWriteTask(Block *b, bool from_read)
Add downloaded block in write queue.
XrdSysTrace * GetTrace() const
Cache(XrdSysLogger *logger, XrdOucEnv *env)
Constructor.
bool Decide(XrdOucCacheIO *)
Makes decision if the original XrdOucCacheIO should be cached.
int UnlinkFile(const std::string &f_name, bool fail_if_open)
Remove cinfo and data files from cache.
virtual XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int opts=0)=0
Obtain a new IO object that fronts existing XrdOucCacheIO.
static XrdScheduler * schedP
File * GetNextFileToPrefetch()
ResourceMonitor & RefResMon()
long long WritesSinceLastCall()
void ProcessWriteTasks()
Separate task which writes blocks from ram to disk.
virtual int Unlink(const char *url)
void RemoveWriteQEntriesFor(File *f)
Remove blocks from write queue which belong to given prefetch. This method is used at the time of Fil...
static const Cache & TheOne()
bool prefetch_str2value(const char *from, const char *str, int &val, int min, int max) const
static bool VCheck(XrdVersionInfo &urVersion)
Version check.
char * RequestRAM(long long size)
virtual int Prepare(const char *url, int oflags, mode_t mode)
bool DecideIfConsideredCached(long long file_size, long long bytes_on_disk)
static Cache & CreateInstance(XrdSysLogger *logger, XrdOucEnv *env)
Singleton creation.
XrdSysError * GetLog() const
bool is_prefetch_enabled() const
void ScheduleFileSync(File *f)
Base cache-io class that implements some XrdOucCacheIO abstract methods.
Base class for reguesting directory space to obtain.
Contains parameters configurable from the xrootd config file.
long long m_hdfsbsize
used with m_hdfsmode, default 128MB
long long m_RamAbsAvailable
available from configuration
long long m_flushCnt
nuber of unsynced blcoks on disk before flush is called
long long m_cgi_max_bufferSize
max buffer size allowed in pfc.blocksize
int m_accHistorySize
max number of entries in access history part of cinfo file
int m_cgi_min_prefetch_max_blocks
min prefetch block count allowed in pfc.prefetch
bool does_cschk_have_missing_bits(CkSumCheck_e cks_on_file) const
bool m_cgi_prefetch_allowed
allow cgi setting of prefetch
int m_wqueue_threads
number of threads writing blocks to disk
long long m_diskTotalSpace
total disk space on configured partition or oss space
long long m_fileUsageMax
cache purge - files usage maximum
long long m_fileUsageBaseline
cache purge - files usage baseline
int m_dirStatsStoreDepth
maximum depth for statistics write out
bool m_allow_xrdpfc_command
flag for enabling access to /xrdpfc-command/ functionality.
bool is_purge_plugin_set_up() const
long long m_diskUsageHWM
cache purge - disk usage high water mark
bool is_cschk_cache() const
std::set< std::string > m_dirStatsDirGlobs
directory globs for which stat reporting was requested
static constexpr long long s_min_bufferSize
CkSumCheck_e get_cs_Chk() const
static constexpr long long s_max_bufferSize
bool is_uvkeep_purge_in_effect() const
int m_prefetch_max_blocks
default maximum number of blocks to prefetch per file
bool are_file_usage_limits_set() const
bool is_cschk_any() const
bool m_cs_ChkTLS
Allow TLS.
long long m_fileUsageNominal
cache purge - files usage nominal
int m_cs_Chk
Checksum check.
bool should_uvkeep_purge(time_t delta) const
int m_purgeAgeBasedPeriod
peform cold file / uvkeep purge every this many purge cycles
bool m_hdfsmode
flag for enabling block-level operation
int m_purgeColdFilesAge
purge files older than this age
std::string m_data_space
oss space for data files
bool is_cschk_both() const
std::set< std::string > m_dirStatsDirs
directories for which stat reporting was requested
long long m_diskUsageLWM
cache purge - disk usage low water mark
int m_RamKeepStdBlocks
number of standard-sized blocks kept after release
long long m_bufferSize
cache block size, default 128 kB
long long m_cgi_min_bufferSize
min buffer size allowed in pfc.blocksize
int m_dirStatsInterval
time between resource monitor statistics dump in seconds
std::string m_meta_space
oss space for metadata files (cinfo)
int m_wqueue_blocks
maximum number of blocks written per write-queue loop
bool is_age_based_purge_in_effect() const
int m_cgi_max_prefetch_max_blocks
max prefetch block count allowed in pfc.prefetch
std::string m_username
username passed to oss plugin
static constexpr int s_max_prefetch_max_blocks
bool m_cgi_blocksize_allowed
allow cgi setting of blocksize
bool is_cschk_net() const
double m_onlyIfCachedMinFrac
minimum fraction of downloaded file, used by only-if-cached CGI option
time_t m_cs_UVKeep
unverified checksum cache keep
int m_purgeInterval
sleep interval between cache purges
long long m_onlyIfCachedMinSize
minumum size of downloaded file, used by only-if-cached CGI option
bool is_dir_stat_reporting_on() const
std::string m_diskUsageLWM
std::string m_diskUsageHWM
std::string m_fileUsageBaseline
std::string m_fileUsageNominal
std::string m_fileUsageMax