bes
Updated for version 3.20.6
|
30 using std::istringstream;
35 #include "BESUncompressManager3.h"
36 #include "BESUncompress3GZ.h"
37 #include "BESUncompress3BZ2.h"
38 #include "BESUncompress3Z.h"
40 #include "BESFileLockingCache.h"
42 #include "BESInternalError.h"
45 #include "TheBESKeys.h"
58 BESUncompressManager3::BESUncompressManager3()
76 BESUncompressManager3::UCIter i;
77 i = _uncompress_list.find(name);
78 if (i == _uncompress_list.end()) {
79 _uncompress_list[name] = method;
95 BESUncompressManager3::UCIter i;
96 i = _uncompress_list.find(name);
97 if (i != _uncompress_list.end()) {
137 BESDEBUG(
"uncompress2",
"BESUncompressManager3::uncompress() - src: " << src << endl );
150 std::ostringstream oss;
151 oss <<
"BESUncompressManager3::" << __func__ <<
"() - ";
152 oss <<
"The supplied Cache object is NULL. Decompression Requires An Operational Cache.";
157 string::size_type dot = src.rfind(
".");
158 if (dot == string::npos) {
159 BESDEBUG(
"uncompress2",
"BESUncompressManager3::uncompress() - no file extension" << endl );
163 string ext = src.substr(dot + 1, src.length() - dot);
169 BESDEBUG(
"uncompress2",
"BESUncompressManager3::uncompress() - not compressed " << endl );
178 BESDEBUG(
"uncompress2",
"BESUncompressManager3::uncompress() - is cached? " << src << endl );
182 BESDEBUG(
"uncompress",
"BESUncompressManager3::uncompress() - cached hit: " << cache_file << endl );
189 BESDEBUG(
"uncompress",
"BESUncompressManager3::uncompress() - caching " << cache_file << endl );
211 BESDEBUG(
"uncompress",
"BESUncompressManager3::uncompress() - cached hit: " << cache_file << endl );
219 BESDEBUG(
"uncompress",
"BESUncompressManager3::uncompress() - caught exception, unlocking cache and re-throw." << endl );
236 strm << BESIndent::LMarg <<
"BESUncompressManager3::dump - (" << (
void *)
this <<
")" << endl;
238 if (_uncompress_list.size()) {
239 strm << BESIndent::LMarg <<
"registered uncompression methods:" << endl;
241 BESUncompressManager3::UCIter i = _uncompress_list.begin();
242 BESUncompressManager3::UCIter ie = _uncompress_list.end();
243 for (; i != ie; i++) {
244 strm << BESIndent::LMarg << (*i).first << endl;
246 BESIndent::UnIndent();
249 strm << BESIndent::LMarg <<
"registered uncompress methods: none" << endl;
251 BESIndent::UnIndent();
255 BESUncompressManager3::TheManager()
257 if (_instance == 0) {
virtual bool get_read_lock(const std::string &target, int &fd)
Get a read-only lock on the file if it exists.
static void uncompress(const std::string &src, int dest_fd)
uncompress a file with the .gz file extension
virtual bool create_and_lock(const std::string &target, int &fd)
Create a file in the cache and lock it for write access.
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 ...
virtual bool add_method(const std::string &name, p_bes_uncompress method)
create_and_lock a uncompress method to the list
virtual p_bes_uncompress find_method(const std::string &name)
returns the uncompression method specified
static void uncompress(const std::string &src, int fd)
uncompress a file with the .gz file extension
List of all registered decompression methods.
exception thrown if internal error encountered
Implementation of a caching mechanism for compressed data.
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual unsigned long long update_cache_info(const std::string &target)
Update the cache info file to include 'target'.
virtual std::string get_cache_file_name(const std::string &src, bool mangle=true)
virtual void update_and_purge(const std::string &new_file)
Purge files from the cache.
virtual void unlock_cache()
static void uncompress(const std::string &src, int fd)
uncompress a file with the .bz2 file extension
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 void exclusive_to_shared_lock(int fd)
Transfer from an exclusive lock to a shared lock.