CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
catalog::CatalogBalancer< CatalogMgrT > Class Template Reference

#include <catalog_balancer.h>

Classes

struct  VirtualNode
 

Public Types

typedef CatalogMgrT::catalog_t catalog_t
 

Public Member Functions

 CatalogBalancer (CatalogMgrT *catalog_mgr)
 
void Balance (catalog_t *catalog)
 

Private Types

typedef CatalogBalancer
< CatalogMgrT >::VirtualNode 
virtual_node_t
 

Private Member Functions

void PartitionOptimally (VirtualNode *virtual_node)
 
void AddCatalogMarker (std::string path)
 
DirectoryEntryBase MakeEmptyDirectoryEntryBase (std::string name, uid_t uid, gid_t gid)
 
void AddCatalog (VirtualNode *child_node)
 

Static Private Member Functions

static VirtualNodeMaxChild (VirtualNode *virtual_node)
 

Private Attributes

CatalogMgrT * catalog_mgr_
 

Detailed Description

template<class CatalogMgrT>
class catalog::CatalogBalancer< CatalogMgrT >

This class is in charge of "balancing" a catalog embedded in a WritableCatalogManager. The process of balancing consists of keeping the number of entries in each catalog between a maximum and minimum threshold so that all of them can be easily manipulable. This way there won't be catalogs that take a lot of time being downloaded, or their SQL operations will take a reasonable amount of time.

The CatalogBalancer uses the following WritableCatalogManager attributes:

  • max_weight_: maximum number of entries in a catalog
  • min_weight_: minimum number of entries in a catalog
  • balance_weight_: maximum number of entries during the balancing process

The balancing process is done traversing the entire catalog tree in postorder, so that the deepest catalogs are analyzed before their parents. Each catalog is then analyzed individually, existing three different scenarios:

a) The number of entries of the catalog is between max_weight_ and min_weight_: nothing happens, the catalog remains untouched.

b) The number of entries of the catalog is greater than max_weight_: the catalog gets split in smaller catalogs. One of the new generated catalogs will be mounted in the original mount point.

c) The number of entries of the catalog is lesser than min_weight_: the catalog gets merged with its father (except the root catalog, obviously).

Definition at line 46 of file catalog_balancer.h.

Member Typedef Documentation

template<class CatalogMgrT>
typedef CatalogMgrT::catalog_t catalog::CatalogBalancer< CatalogMgrT >::catalog_t

Definition at line 48 of file catalog_balancer.h.

template<class CatalogMgrT>
typedef CatalogBalancer<CatalogMgrT>::VirtualNode catalog::CatalogBalancer< CatalogMgrT >::virtual_node_t
private

Definition at line 128 of file catalog_balancer.h.

Constructor & Destructor Documentation

template<class CatalogMgrT>
catalog::CatalogBalancer< CatalogMgrT >::CatalogBalancer ( CatalogMgrT *  catalog_mgr)
inlineexplicit

Definition at line 49 of file catalog_balancer.h.

Member Function Documentation

template<class CatalogMgrT >
void catalog::CatalogBalancer< CatalogMgrT >::AddCatalog ( VirtualNode child_node)
private

Definition at line 154 of file catalog_balancer_impl.h.

Here is the call graph for this function:

template<class CatalogMgrT>
void catalog::CatalogBalancer< CatalogMgrT >::AddCatalogMarker ( std::string  path)
private

Definition at line 58 of file catalog_balancer_impl.h.

Here is the call graph for this function:

template<class CatalogMgrT >
void catalog::CatalogBalancer< CatalogMgrT >::Balance ( catalog_t catalog)

This method balances a catalog. A catalog is considered overflowed if its weight (the number of entries in the catalog database) is greater than the stablish threshold defined by the max_weight_ variable. If a catalog is overflowed it will be split in a number of new catalogs, meeting the following properties:

  • There will be a catalog in the same place where the overflowed catalog was at the beginning of the process.
  • New generated catalogs will have a maximum weight defined by the attribute balance_weight_, which will always be lesser than max_weight_.
  • The number of new generated catalogs is unknown.

A catalog is considered underflowed if its weight is lesser than the minimum threshold, defined by the min_weight_ variable. If a catalog is underflowed it will be merged with the father catalog. However, it is remarkable that such an operation can provoke an overflow in the father, which will be threaten separately.

If a catalog is not overflowed or underflowed no changes will be applied to it.

For a WritableCatalogManager to be balanced it requires the is_balanced_ flag to be set to true.

Parameters
catalogthe catalog to be balanced, or NULL to balance all catalogs in the WritableCatalogManager

Definition at line 76 of file catalog_balancer_impl.h.

Referenced by catalog::WritableCatalogManager::FixWeight().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class CatalogMgrT>
DirectoryEntryBase catalog::CatalogBalancer< CatalogMgrT >::MakeEmptyDirectoryEntryBase ( std::string  name,
uid_t  uid,
gid_t  gid 
)
private

Definition at line 29 of file catalog_balancer_impl.h.

Here is the call graph for this function:

template<class CatalogMgrT >
CatalogBalancer< CatalogMgrT >::VirtualNode * catalog::CatalogBalancer< CatalogMgrT >::MaxChild ( VirtualNode virtual_node)
staticprivate

Definition at line 132 of file catalog_balancer_impl.h.

Here is the call graph for this function:

template<class CatalogMgrT >
void catalog::CatalogBalancer< CatalogMgrT >::PartitionOptimally ( VirtualNode virtual_node)
private

Definition at line 96 of file catalog_balancer_impl.h.

Here is the call graph for this function:

Member Data Documentation

template<class CatalogMgrT>
CatalogMgrT* catalog::CatalogBalancer< CatalogMgrT >::catalog_mgr_
private

Definition at line 138 of file catalog_balancer.h.


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