1 #ifndef __XRDPFC_CACHE_HH__
2 #define __XRDPFC_CACHE_HH__
26 #include "XrdVersion.hh"
169 virtual int LocalFilePath(
const char *url,
char *buff=0,
int blen=0,
174 virtual int Prepare(
const char *url,
int oflags, mode_t mode);
177 virtual int Stat(
const char *url,
struct stat &sbuff);
180 virtual int Unlink(
const char *url);
214 bool Config(
const char *config_filename,
const char *parameters);
233 static bool VCheck(XrdVersionInfo &urVersion) {
return true; }
238 int UnlinkFile(
const std::string& f_name,
bool fail_if_open);
274 File*
GetFile(
const std::string&,
IO*,
long long off = 0,
long long filesize = 0);
299 bool test_oss_basics_and_features();
301 bool cfg2bytes(
const std::string &str,
long long &store,
long long totalSpace,
const char *name);
303 static Cache *m_instance;
308 const char *m_traceID;
316 std::vector<Decision*> m_decisionpoints;
322 bool m_prefetch_enabled;
325 long long m_RAM_used;
326 long long m_RAM_write_queue;
327 std::list<char*> m_RAM_std_blocks;
331 bool m_dataXattr =
false;
332 bool m_metaXattr =
false;
336 WriteQ() : condVar(0), writes_between_purges(0), size(0) {}
339 std::list<Block*> queue;
340 long long writes_between_purges;
347 typedef std::map<std::string, File*> ActiveMap_t;
348 typedef ActiveMap_t::iterator ActiveMap_i;
349 typedef std::set<std::string> FNameSet_t;
351 ActiveMap_t m_active;
352 FNameSet_t m_purge_delay_set;
355 void inc_ref_cnt(
File*,
bool lock,
bool high_debug);
356 void dec_ref_cnt(
File*,
bool high_debug);
358 void schedule_file_sync(
File*,
bool ref_cnt_already_set,
bool high_debug);
361 typedef std::vector<File*> PrefetchList;
362 PrefetchList m_prefetchList;
int stat(const char *path, struct stat *buf)
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 Config(const char *config_filename, const char *parameters)
Parse configuration file.
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.
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.
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()
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.
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
int m_accHistorySize
max number of entries in access history part of cinfo file
bool does_cschk_have_missing_bits(CkSumCheck_e cks_on_file) const
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
depth to which statistics should be collected
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
CkSumCheck_e get_cs_Chk() const
bool is_uvkeep_purge_in_effect() const
int m_prefetch_max_blocks
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
prefetch buffer size, default 1MB
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
std::string m_username
username passed to oss plugin
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_dirStatsMaxDepth
maximum depth for statistics write out
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