29 #ifndef BESFileLockingCache_h_ 30 #define BESFileLockingCache_h_ 1 44 unsigned long long size;
48 typedef std::list<cache_entry> CacheFiles;
75 static const char DAP_CACHE_CHAR =
'#';
89 unsigned long long d_target_size;
97 void m_check_ctor_params();
98 void m_initialize_cache_info();
100 unsigned long long m_collect_cache_dir_info(CacheFiles &contents);
106 void m_record_descriptor(
const string &file,
int fd);
107 int m_get_descriptor(
const string &file);
110 typedef std::multimap<string, int> FilesAndLockDescriptors;
111 FilesAndLockDescriptors d_locks;
118 void initialize(
const string &cache_dir,
const string &prefix,
unsigned long long size);
119 BESFileLockingCache(
const string &cache_dir,
const string &prefix,
unsigned long long size);
120 virtual ~
BESFileLockingCache() {
if (d_cache_info_fd != -1){ close(d_cache_info_fd); d_cache_info_fd=-1;} }
139 virtual bool cache_too_big(
unsigned long long current_size)
const;
144 const string getCacheFilePrefix();
145 const string getCacheDirectory();
151 virtual void dump(ostream &strm)
const ;
154 #endif // BESFileLockingCache_h_ virtual void unlock_cache()
virtual bool cache_too_big(unsigned long long current_size) const
look at the cache size; is it too large? Look at the cache size and see if it is too big...
virtual bool create_and_lock(const string &target, int &fd)
Create a file in the cache and lock it for write access. If the file does not exist, make it, open it for read-write access and get an exclusive lock on it. The locking operation blocks, although that should never happen.
virtual unsigned long long get_cache_size()
Get the cache size. Read the size information from the cache info file and return it...
Implementation of a caching mechanism for compressed data. This cache uses simple advisory locking fo...
Base object for bes objects.
static bool dir_exists(const string &dir)
virtual void purge_file(const string &file)
Purge a single file from the cache.
virtual void lock_cache_write()
virtual void dump(ostream &strm) const
dumps information about this object
virtual string get_cache_file_name(const string &src, bool mangle=true)
virtual bool get_read_lock(const string &target, int &fd)
Get a read-only lock on the file if it exists.
virtual void update_and_purge(const string &new_file)
Purge files from the cache.
virtual unsigned long long update_cache_info(const string &target)
Update the cache info file to include 'target'.
unsigned long long d_max_cache_size_in_bytes
How many bytes can the cache hold before we have to purge.
virtual void lock_cache_read()
virtual void exclusive_to_shared_lock(int fd)
Transfer from an exclusive lock to a shared lock. If the file has an exclusive write lock on it...
virtual bool getExclusiveLock(string file_name, int &ref_fd)
virtual void unlock_and_close(const string &target)