bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESUncompressManager3 Class Reference

List of all registered decompression methods. More...

#include <BESUncompressManager3.h>

Inheritance diagram for BESUncompressManager3:
Inheritance graph
Collaboration diagram for BESUncompressManager3:
Collaboration graph

Public Member Functions

virtual bool add_method (const std::string &name, p_bes_uncompress method)
 create_and_lock a uncompress method to the list
 
 BESUncompressManager3 ()
 constructs an uncompression manager adding gz, z, and bz2 uncompression methods by default.
 
virtual void dump (std::ostream &strm) const
 dumps information about this object
 
virtual p_bes_uncompress find_method (const std::string &name)
 returns the uncompression method specified
 
virtual bool uncompress (const std::string &src, std::string &target, BESFileLockingCache *cache)
 If the file 'src' should be uncompressed, do so and return a new file name on the value-result param 'target'.
 

Static Public Member Functions

static BESUncompressManager3TheManager ()
 

Detailed Description

List of all registered decompression methods.

The BESUncompressManager3 allows the developer to add or remove named decompression methods from the list for this server. By default a gz and bz2 and Z function is provided.

What is actually added to the list are static decompression functions. Each of these functions is responsible for decompressing a specific type of compressed file. The manager knows which type to decompress by the file extension.

See also
BESUncompressGZ
BESUncompressBZ2
BESUncompressZ
BESCache

Definition at line 56 of file BESUncompressManager3.h.

Constructor & Destructor Documentation

◆ BESUncompressManager3()

BESUncompressManager3::BESUncompressManager3 ( )

constructs an uncompression manager adding gz, z, and bz2 uncompression methods by default.

Adds methods to uncompress gz, bz2, and Z files.

Looks for a configuration parameter for the number of times to try to lock the cache (BES.Uncompress.NumTries) and the time in microseconds between tries (BES.Uncompress.Retry).

Definition at line 63 of file BESUncompressManager3.cc.

◆ ~BESUncompressManager3()

BESUncompressManager3::~BESUncompressManager3 ( )
virtual

Definition at line 70 of file BESUncompressManager3.cc.

Member Function Documentation

◆ add_method()

bool BESUncompressManager3::add_method ( const std::string & name,
p_bes_uncompress method )
virtual

create_and_lock a uncompress method to the list

This method actually adds to the list a static method that knows how to uncompress a particular type of file. For example, a .gz or .bz2 file.

Parameters
namename of the method to add to the list
methodthe static function that uncompress the particular type of file
Returns
true if successfully added, false if it already exists

Definition at line 81 of file BESUncompressManager3.cc.

◆ dump()

void BESUncompressManager3::dump ( std::ostream & strm) const
virtual

dumps information about this object

Displays the pointer value of this instance along with the names of the registered decompression methods.

Parameters
strmC++ i/o stream to dump the information to

Implements BESObj.

Definition at line 251 of file BESUncompressManager3.cc.

◆ find_method()

p_bes_uncompress BESUncompressManager3::find_method ( const std::string & name)
virtual

returns the uncompression method specified

This method looks up the uncompression method with the given name and returns that method.

Parameters
namename of the uncompression method to find
Returns
the function of type p_bes_uncompress

Definition at line 102 of file BESUncompressManager3.cc.

◆ TheManager()

BESUncompressManager3 * BESUncompressManager3::TheManager ( )
static

Definition at line 274 of file BESUncompressManager3.cc.

◆ uncompress()

bool BESUncompressManager3::uncompress ( const std::string & src,
std::string & target,
BESFileLockingCache * cache )
virtual

If the file 'src' should be uncompressed, do so and return a new file name on the value-result param 'target'.

This code tests that the file named by 'src' really should be uncompressed, returning false if it clearly should not (i.e., it does not end in an extension like '.gz') or cannot. If the file is uncompressed, this code takes care of doing all the stuff that needs to happen as far as caching the uncompressed data, ensuring that the file holding those data is locked for read-only access.

When new data are added to the cache, this code checks the size and, if the cache is too large, uses a LRU algorithm to remove files to make room for the new file.

Note
As implemented, the purge() code removes files so that the resulting size of the cache will be about 80% of the maximum size of the cache as set in the bes.conf file.
If there is a problem uncompressing the file, the uncompress code is responsible for closing the source file, the target file, AND REMOVING THE TARGET FILE. If the target file is left in place after an error, then the cache might use that file in the future for a request.
Parameters
srcfile to be uncompressed
cache_fileName of file to uncompress into
cacheBESCache object to uncompress the src file in
Returns
true if the file's contents are in the cache and at the pathname cfile
Exceptions
BESInternalErrorif there is a problem uncompressing the file

If the cache object is a null pointer then we can't go further, and we know that the item isn't in the cache. FIXME IS THIS AN ERROR?? I think maybe it's fine returning false and not throwing because this means the down stream software will try to read the file and, since this test is after checks that determine if the file appears to be compressed, will fail. This may however be difficult to diagnose for the users.

Definition at line 146 of file BESUncompressManager3.cc.


The documentation for this class was generated from the following files: