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.
template<class CatalogMgrT >
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
-
Definition at line 76 of file catalog_balancer_impl.h.
Referenced by catalog::WritableCatalogManager::FixWeight().