|
bool | cache_enabled () const |
|
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 std::string &target, int &fd) |
| Create a file in the cache and lock it for write access.
|
|
void | disable () |
| Disable the cache.
|
|
void | dump (std::ostream &strm) const override |
| dumps information about this object
|
|
void | enable () |
| Enable the cache.
|
|
virtual void | exclusive_to_shared_lock (int fd) |
| Transfer from an exclusive lock to a shared lock.
|
|
std::string | get_cache_directory () const |
|
virtual std::string | get_cache_file_name (const std::string &src, bool mangle=true) |
|
std::string | get_cache_file_prefix () const |
|
virtual unsigned long long | get_cache_size () |
| Get the cache size.
|
|
bool | get_data_from_cache (const std::string &cache_file_name, int64_t expected_file_size, int &fd) |
|
virtual bool | get_exclusive_lock (const std::string &target, int &fd) |
|
virtual bool | get_exclusive_lock_nb (const std::string &target, int &fd) |
|
virtual bool | get_read_lock (const std::string &target, int &fd) |
| Get a read-only lock on the file if it exists.
|
|
void | initialize (const std::string &cache_dir, const std::string &prefix, unsigned long long size) |
| Initialize an instance of FileLockingCache.
|
|
bool | is_unlimited () const |
| Is this cache allowed to store as much as it wants?
|
|
bool | is_valid (const std::string &cache_file_name, int64_t expected_file_size) const |
|
virtual void | purge_file (const std::string &file) |
| Purge a single file from the cache.
|
|
virtual void | unlock_and_close (const std::string &target) |
|
virtual void | update_and_purge (const std::string &new_file) |
| Purge files from the cache.
|
|
virtual unsigned long long | update_cache_info (const std::string &target) |
| Update the cache info file to include 'target'.
|
|
bool | write_cached_data (const std::string &cache_file_name, int64_t expected_file_size, const std::vector< double > &val) |
|
bool | write_cached_data2 (const std::string &cache_file_name, int64_t expected_file_size, const void *buf) |
|
Definition at line 16 of file HDF5DiskCache.h.
bool BESFileLockingCache::create_and_lock |
( |
const std::string & | target, |
|
|
int & | fd ) |
|
virtualinherited |
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.
- Parameters
-
target | The name of the file to make/open/lock |
fd | Value-result param that holds the file descriptor of the opened file |
- Returns
- True if the operation was successful, false otherwise. This method will return false if the file already existed (the file won't be locked and the descriptor reference is undefined - but likely -1).
- Exceptions
-
BESBESInternalError | if any error except EEXIST is returned by open(2) or if fcntl(2) returns an error. |
Definition at line 625 of file BESFileLockingCache.cc.
void BESFileLockingCache::exclusive_to_shared_lock |
( |
int | fd | ) |
|
|
virtualinherited |
Transfer from an exclusive lock to a shared lock.
If the file has an exclusive write lock on it, change that to a shared read lock. This is an atomic operation. If the call to fcntl(2) is protected by locking the cache, a dead lock will result given typical use of this class. This method exists to help with the situation where one process has the cache locked and is blocking on a shared read lock for a file that a second process has locked exclusively (for writing). By changing the exclusive lock to a shared lock, the first process can get its shared lock and then release the cache.
- Parameters
-
fd | The file descriptor that is exclusively locked and which, on exit, will have a shared lock. |
Definition at line 660 of file BESFileLockingCache.cc.
void BESFileLockingCache::initialize |
( |
const std::string & | cache_dir, |
|
|
const std::string & | prefix, |
|
|
unsigned long long | size ) |
|
inherited |
Initialize an instance of FileLockingCache.
Initialize and instance of FileLockingCache using the passed values for the cache directory, item prefix and max cache size. This will ignore the value of enable_cache() (but will correctly (re)set it based on the directory, ..., values). This provides a way for clients to re-initialize caches on the fly.
- Parameters
-
cache_dir | The directory into which the cache files will be written. |
prefix | The prefix that will be added to each cache file. |
size | The size of the cache in MBytes |
- Exceptions
-
BESInternalError | If the cache_dir does not exist or is not writable. size is 0, or if cache dir does not exist. |
BESError | If the parameters (directory, ...) are invalid. |
Definition at line 259 of file BESFileLockingCache.cc.
void BESFileLockingCache::purge_file |
( |
const std::string & | file | ) |
|
|
virtualinherited |
Purge a single file from the cache.
Purge a single file from the cache. The file might be old, etc., and need to be removed. Don't use this to shrink the cache when it gets too big, use update_and_purge() instead since that file optimizes accesses to the cache control file for several changes in a row.
- Parameters
-
file | The name of the file to purge. |
Definition at line 1125 of file BESFileLockingCache.cc.
void BESFileLockingCache::unlock_and_close |
( |
const std::string & | target | ) |
|
|
virtualinherited |
Get an exclusive lock on the 'cache info' file. The 'cache info' file is used to control certain cache actions, ensuring that they are atomic. These include making sure that the create_and_lock() and read_and_lock() operations are atomic as well as the purge and related operations.
- Note
- This is intended to be used internally only but might be useful in some settings. Unlock the named file.
This does not do any name mangling; it just closes and unlocks whatever is named (or throws BESBESInternalError if the file cannot be closed). If the file was opened more than once, all descriptors are closed. If you need to close a specific descriptor, use the other version of unlock_and_close().
- Note
- This method assumes that the file was opened/locked using one of read_and_lock() or create_and_lock(). Those methods record the name/file- descriptor pairs so that the files can be properly closed and locks released.
- Parameters
-
file_name | The name of the file to unlock. |
- Exceptions
-
Definition at line 745 of file BESFileLockingCache.cc.