bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
|
#include <AggMemberDatasetDimensionCache.h>
Public Member Functions | |
AggMemberDatasetDimensionCache (const AggMemberDatasetDimensionCache &src)=delete | |
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. | |
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? | |
void | loadDimensionCache (AggMemberDataset *amd) |
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'. | |
Static Public Member Functions | |
static bool | dir_exists (const std::string &dir) |
static AggMemberDatasetDimensionCache * | get_instance () |
static AggMemberDatasetDimensionCache * | get_instance (const std::string &bes_catalog_root_dir, const std::string &stored_results_subdir, const std::string &prefix, unsigned long long size) |
Static Public Attributes | |
static const std::string | CACHE_DIR_KEY = "NCML.DimensionCache.directory" |
static const std::string | PREFIX_KEY = "NCML.DimensionCache.prefix" |
static const std::string | SIZE_KEY = "NCML.DimensionCache.size" |
Protected Member Functions | |
AggMemberDatasetDimensionCache (const std::string &data_root_dir, const std::string &stored_results_subdir, const std::string &prefix, unsigned long long size) | |
This child of BESFileLockingCache manifests a cache for the ncml_handler in which AggMemberDataset's dimension values are stored. This allows the ncml_handler to make one (slow) pass over the aggregation member dataset list, collect all of the dimension information anmd cache it. Then, the next time the aggregation is accessed loading the dimension information from the cache goes lickety-split compared with the time needed to retrieve the DDSs from the source datasets. (This is especially true for the hdf4 handler)
This implementation utilizes the BES.Catalog.catalog.RootDirectory/BES.Data.RootDirectory to locate the source dataset files in order to verify of the cache is up-to-date and updates cache components as needed.
Definition at line 32 of file AggMemberDatasetDimensionCache.h.
|
inlineinherited |
Definition at line 200 of file BESFileLockingCache.h.
|
virtualinherited |
look at the cache size; is it too large? Look at the cache size and see if it is too big.
Definition at line 817 of file BESFileLockingCache.cc.
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.
target | The name of the file to make/open/lock |
fd | Value-result param that holds the file descriptor of the opened file |
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.
|
staticinherited |
Does the directory exist?
dir | The pathname to test. |
Definition at line 1190 of file BESFileLockingCache.cc.
|
inlineinherited |
Disable the cache.
Definition at line 205 of file BESFileLockingCache.h.
|
overridevirtualinherited |
dumps information about this object
Displays the pointer value of this instance along with information about this cache.
strm | C++ i/o stream to dump the information to |
Implements BESObj.
Definition at line 1205 of file BESFileLockingCache.cc.
|
inlineinherited |
Enable the cache.
Definition at line 210 of file BESFileLockingCache.h.
|
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.
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.
|
inlineinherited |
Definition at line 191 of file BESFileLockingCache.h.
|
virtualinherited |
Returns the fully qualified file system path name for the cache file associated with this particular cache resource. This does not look in the cache to see if the fle is present, it just returns the name that will (or is) be used once/if the file is added to the cache.
src | The source name to (or in the) cache |
mangle | If True, assume the name is a file pathname and mangle it. If false, do not mangle the name (assume the caller has sent a suitable string) but do turn the string into a pathname located in the cache directory with the cache prefix. The 'mangle' param is true by default. |
Reimplemented in BESUncompressCache.
Definition at line 472 of file BESFileLockingCache.cc.
|
inlineinherited |
Definition at line 186 of file BESFileLockingCache.h.
|
virtualinherited |
Get the cache size.
Read the size information from the cache info file and return it. This methods locks the cache.
Definition at line 829 of file BESFileLockingCache.cc.
|
virtualinherited |
A blocking call to get an exclusive (write) lock on a file in the cache. Because this cache uses per-process advisory locking, it's possible to call this several times from within a single process and get a lock each time.
file_name | Name of the file to lock |
ref_fd | Return value parameter that holds the file descriptor that is locked. |
BESInternalError | is thrown on any condition other than the file not existing |
Definition at line 1079 of file BESFileLockingCache.cc.
|
virtualinherited |
A non-blocking call to get an exclusive (write) lock on a file in the cache. Because this cache uses per-process advisory locking, it's possible to call this several times from within a single process and get a lock each time.
file_name | Name of the file to lock |
ref_fd | Return value parameter that holds the file descriptor that is locked. |
BESInternalError | is thrown on any condition other than the file not existing or the lock being unavailable. |
Definition at line 920 of file BESFileLockingCache.cc.
|
static |
Get the instance of the singleton AggMemberDatasetDimensionCache object. If one has not yet been built a new one will be by interrogating "TheBESKeys" looking for the values of CACHE_DIR_KEY, PREFIX_KEY, and SIZE_KEY to initialize the cache.
Definition at line 210 of file AggMemberDatasetDimensionCache.cc.
Get a read-only lock on the file if it exists.
Try to get a read-only lock on the file, blocking until we can get it. If the file does not exist, return false.
target | The path of the cached file |
fd | A value-result parameter set to the locked cached file. Undefined if the file could not be locked for read access. |
Error | if the attempt to get the (shared) lock failed for any reason other than that the file does/did not exist. |
Definition at line 565 of file BESFileLockingCache.cc.
|
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.
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 |
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.
|
inlineinherited |
Is this cache allowed to store as much as it wants?
If the size of the cache is zero bytes, then it is allowed to grow with out bounds.
Definition at line 181 of file BESFileLockingCache.h.
void agg_util::AggMemberDatasetDimensionCache::loadDimensionCache | ( | AggMemberDataset * | amd | ) |
Loads the dimensions of the passed AggMemberDataset. If the dimensions are in the cache, and the cache file is valid (length>0 and LMT < the LMT of the source dataset file) then the dimensions will be read from the cache file. Otherwise the source data file will be used to build a DDS from which the dimension can be extracted and subsequently cached.
Definition at line 305 of file AggMemberDatasetDimensionCache.cc.
|
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.
file | The name of the file to purge. |
Definition at line 1125 of file BESFileLockingCache.cc.
|
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.
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().
file_name | The name of the file to unlock. |
BESBESInternalError |
Definition at line 745 of file BESFileLockingCache.cc.
|
virtualinherited |
Purge files from the cache.
Purge files, oldest to newest, if the current size of the cache exceeds the size of the cache specified in the constructor. This method uses an exclusive lock on the cache for the duration of the purge process.
new_file | Do not delete this file. The name of a file this process just added to the cache. Using fcntl(2) locking there is no way this process can detect its own lock, so the shared read lock on the new file won't keep this process from deleting it (but will keep other processes from deleting it). |
Definition at line 977 of file BESFileLockingCache.cc.
|
virtualinherited |
Update the cache info file to include 'target'.
Add the size of the named file to the total cache size recorded in the cache info file. The cache info file is exclusively locked by this method for its duration. This updates the cache info file and returns the new size.
target | The name of the file |
Definition at line 769 of file BESFileLockingCache.cc.
|
static |
Definition at line 60 of file AggMemberDatasetDimensionCache.h.
|
static |
Definition at line 61 of file AggMemberDatasetDimensionCache.h.
|
static |
Definition at line 62 of file AggMemberDatasetDimensionCache.h.