CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AbstractObjectFetcher< DerivedT > Class Template Reference

#include <object_fetcher.h>

Inheritance diagram for AbstractObjectFetcher< DerivedT >:
Collaboration diagram for AbstractObjectFetcher< DerivedT >:

Public Types

typedef object_fetcher_traits
< DerivedT >::CatalogTN 
CatalogTN
 
typedef object_fetcher_traits
< DerivedT >::HistoryTN 
HistoryTN
 
typedef object_fetcher_traits
< DerivedT >::ReflogTN 
ReflogTN
 
typedef
ObjectFetcherFailures::Failures 
Failures
 
- Public Types inherited from ObjectFetcherFailures
enum  Failures {
  kFailOk, kFailNotFound, kFailLocalIO, kFailNetwork,
  kFailDecompression, kFailManifestNameMismatch, kFailManifestSignatureMismatch, kFailBadData,
  kFailUnknown, kFailNumEntries
}
 

Public Member Functions

Failures FetchManifest (manifest::Manifest **manifest)
 
Failures FetchHistory (HistoryTN **history, const shash::Any &history_hash=shash::Any())
 
Failures FetchCatalog (const shash::Any &catalog_hash, const std::string &catalog_path, CatalogTN **catalog, const bool is_nested=false, CatalogTN *parent=NULL)
 
Failures FetchReflog (const shash::Any &reflog_hash, ReflogTN **reflog)
 
Failures FetchManifest (UniquePtr< manifest::Manifest > *manifest)
 
Failures FetchHistory (UniquePtr< HistoryTN > *history, const shash::Any &history_hash=shash::Any())
 
Failures FetchCatalog (const shash::Any &catalog_hash, const std::string &catalog_path, UniquePtr< CatalogTN > *catalog, const bool is_nested=false, CatalogTN *parent=NULL)
 
Failures FetchReflog (const shash::Any &reflog_hash, UniquePtr< ReflogTN > *reflog)
 
std::string GetUrl (const shash::Any &hash) const
 
bool HasHistory ()
 
const std::string & temporary_directory () const
 

Static Public Attributes

static const std::string kManifestFilename
 
static const std::string kReflogFilename
 

Protected Member Functions

 AbstractObjectFetcher (const std::string &temp_dir)
 
Failures Fetch (const shash::Any &object_hash, std::string *file_path)
 
Failures Fetch (const std::string &relative_path, const bool decompress, const bool nocache, std::string *file_path)
 
shash::Any GetHistoryHash ()
 

Private Attributes

const std::string temporary_directory_
 

Detailed Description

template<class DerivedT>
class AbstractObjectFetcher< DerivedT >

This is the default class implementing the data object fetching strategy. It is meant to be used when CVMFS specific data structures need to be downloaded from a backend storage of a repository.

ObjectFetchers are supposed to be configured for one specific repository. How this is done depends on the concrete implementation of this base class. When a concrete implementation of ObjectFetcher<> needs to deal with files on the local file system it is obliged to take measures for proper cleanup of those files after usage.

It abstracts all accesses to external file or HTTP resources and gathers this access logic in one central point. This also comes in handy when unit testing components that depend on downloading CVMFS data structures from a repository backend storage like CatalogTraversal<> or GarbageCollector<>.

Definition at line 81 of file object_fetcher.h.

Member Typedef Documentation

template<class DerivedT>
typedef object_fetcher_traits<DerivedT>::CatalogTN AbstractObjectFetcher< DerivedT >::CatalogTN

Definition at line 83 of file object_fetcher.h.

template<class DerivedT>
typedef ObjectFetcherFailures::Failures AbstractObjectFetcher< DerivedT >::Failures

Definition at line 87 of file object_fetcher.h.

template<class DerivedT>
typedef object_fetcher_traits<DerivedT>::HistoryTN AbstractObjectFetcher< DerivedT >::HistoryTN

Definition at line 84 of file object_fetcher.h.

template<class DerivedT>
typedef object_fetcher_traits<DerivedT>::ReflogTN AbstractObjectFetcher< DerivedT >::ReflogTN

Definition at line 85 of file object_fetcher.h.

Constructor & Destructor Documentation

template<class DerivedT>
AbstractObjectFetcher< DerivedT >::AbstractObjectFetcher ( const std::string &  temp_dir)
inlineexplicitprotected

Definition at line 264 of file object_fetcher.h.

Member Function Documentation

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::Fetch ( const shash::Any object_hash,
std::string *  file_path 
)
inlineprotected

Internal function used to download objects defined by the given content hash. This needs to be implemented depending on the concrete implementation of this base class.

Parameters
object_hashthe content hash of the object to be downloaded
file_pathtemporary file path to store the download result
Returns
failure code (if not kFailOk, file_path is invalid)

Definition at line 276 of file object_fetcher.h.

Referenced by AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::Fetch(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchCatalog(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchHistory(), and AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchReflog().

Here is the caller graph for this function:

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::Fetch ( const std::string &  relative_path,
const bool  decompress,
const bool  nocache,
std::string *  file_path 
)
inlineprotected

Definition at line 280 of file object_fetcher.h.

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::FetchCatalog ( const shash::Any catalog_hash,
const std::string &  catalog_path,
CatalogTN **  catalog,
const bool  is_nested = false,
CatalogTN parent = NULL 
)
inline

Downloads and opens a catalog. Note that the user is responsible to remove the catalog object after usage.

Parameters
catalog_hashthe content hash of the catalog object
catalog_paththe root_path the catalog is mounted on
catalogpointer to the fetched catalog object pointer
is_nesteda hint if the catalog to be loaded is a nested one
parent(optional) parent catalog of the requested catalog
Returns
failure code, specifying the action's result

Definition at line 155 of file object_fetcher.h.

Referenced by swissknife::RootChainWalker::FetchCatalog(), and AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchCatalog().

Here is the caller graph for this function:

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::FetchCatalog ( const shash::Any catalog_hash,
const std::string &  catalog_path,
UniquePtr< CatalogTN > *  catalog,
const bool  is_nested = false,
CatalogTN parent = NULL 
)
inline

Definition at line 226 of file object_fetcher.h.

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::FetchHistory ( HistoryTN **  history,
const shash::Any history_hash = shash::Any() 
)
inline

Downloads and opens (read-only) a history database. Note that the user is responsible to remove the history object after usage. The fetched SQLite database file will be unlinked automatically during the destruction of the HistoryTN object.

Parameters
historypointer to a history database object pointer
history_hash(optional) the content hash of the history database if left blank, the latest one is downloaded
Returns
failure code, specifying the action's result

Definition at line 115 of file object_fetcher.h.

Referenced by swissknife::RootChainWalker::FetchHistory(), and AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchHistory().

Here is the caller graph for this function:

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::FetchHistory ( UniquePtr< HistoryTN > *  history,
const shash::Any history_hash = shash::Any() 
)
inline

Definition at line 218 of file object_fetcher.h.

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::FetchManifest ( manifest::Manifest **  manifest)
inline

Fetches and opens the manifest of the repository this object fetcher is configured for. Note that the user is responsible to clean up this object.

Parameters
manifestpointer to a manifest object pointer
Returns
failure code, specifying the action's result

Definition at line 100 of file object_fetcher.h.

Referenced by AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchManifest(), and AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::GetHistoryHash().

Here is the caller graph for this function:

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::FetchManifest ( UniquePtr< manifest::Manifest > *  manifest)
inline

Definition at line 211 of file object_fetcher.h.

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::FetchReflog ( const shash::Any reflog_hash,
ReflogTN **  reflog 
)
inline

Definition at line 182 of file object_fetcher.h.

Referenced by AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchReflog().

Here is the caller graph for this function:

template<class DerivedT>
Failures AbstractObjectFetcher< DerivedT >::FetchReflog ( const shash::Any reflog_hash,
UniquePtr< ReflogTN > *  reflog 
)
inline

Definition at line 241 of file object_fetcher.h.

template<class DerivedT>
shash::Any AbstractObjectFetcher< DerivedT >::GetHistoryHash ( )
inlineprotected

Retrieves the history content hash of the HEAD history database from the repository's manifest

Returns
the content hash of the HEAD history db or a null-hash on error

Definition at line 296 of file object_fetcher.h.

Referenced by AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchHistory(), and AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::HasHistory().

Here is the caller graph for this function:

template<class DerivedT>
std::string AbstractObjectFetcher< DerivedT >::GetUrl ( const shash::Any hash) const
inline

Definition at line 250 of file object_fetcher.h.

Referenced by AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::GetUrl().

Here is the caller graph for this function:

template<class DerivedT>
bool AbstractObjectFetcher< DerivedT >::HasHistory ( )
inline

Definition at line 254 of file object_fetcher.h.

template<class DerivedT>
const std::string& AbstractObjectFetcher< DerivedT >::temporary_directory ( ) const
inline

Definition at line 259 of file object_fetcher.h.

Referenced by HttpObjectFetcher< CatalogT, HistoryT, ReflogT >::Download(), and LocalObjectFetcher< CatalogT, HistoryT, ReflogT >::Fetch().

Here is the caller graph for this function:

Member Data Documentation

template<class DerivedT>
const std::string AbstractObjectFetcher< DerivedT >::kManifestFilename
static
template<class DerivedT>
const std::string AbstractObjectFetcher< DerivedT >::kReflogFilename
static
Initial value:
=
".cvmfsreflog"

Definition at line 90 of file object_fetcher.h.

Referenced by AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchReflog().

template<class DerivedT>
const std::string AbstractObjectFetcher< DerivedT >::temporary_directory_
private

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