5 #ifndef CVMFS_CATALOG_BALANCER_IMPL_H_
6 #define CVMFS_CATALOG_BALANCER_IMPL_H_
27 template <
class CatalogMgrT>
38 void *empty_compressed;
39 uint64_t sz_empty_compressed;
41 NULL, 0, &empty_compressed, &sz_empty_compressed);
44 sz_empty_compressed, &file_hash);
45 free(empty_compressed);
49 deb.
mode_ = S_IFREG | S_IRUSR | S_IWUSR;
57 template <
class CatalogMgrT>
65 MakeEmptyDirectoryEntryBase(
".cvmfscatalog", parent.
uid(),
68 MakeEmptyDirectoryEntryBase(
".cvmfsautocatalog", parent.
uid(),
70 string relative_path = path.substr(1);
75 template <
class CatalogMgrT>
77 if (catalog == NULL) {
83 reverse(catalogs.begin(), catalogs.end());
84 for (
unsigned i = 0; i < catalogs.size(); ++i)
88 string catalog_path = catalog->mountpoint().ToString();
92 PartitionOptimally(&root_node);
95 template <
class CatalogMgrT>
99 for (
unsigned i = 0; i < virtual_node->
children.size(); ++i) {
103 PartitionOptimally(virtual_child);
108 MaxChild(virtual_node);
111 if (heaviest_node != NULL &&
115 unsigned max_weight = heaviest_node->
weight;
116 AddCatalogMarker(heaviest_node->
path);
117 AddCatalog(heaviest_node);
118 virtual_node->
weight -= (max_weight - 1);
123 " in any subdirectory of '%s' even though"
124 " currently it is overflowed", virtual_node->
path.c_str());
130 template <
class CatalogMgrT>
136 unsigned max_weight = 0;
140 for (
unsigned i = 0; i < virtual_node->
children.size(); ++i) {
144 max_weight < child->
weight) {
145 max_weight = child->
weight;
153 template <
class CatalogMgrT>
155 assert(child_node != NULL);
156 string new_catalog_path = child_node->
path.substr(1);
161 " catalog in '%s'", child_node->
path.c_str());
164 template <
class CatalogMgrT>
166 CatalogMgrT *catalog_mgr) {
168 catalog_mgr->Listing(path, &direntlist);
169 for (
unsigned i = 0; i < direntlist.size(); ++i) {
170 string child_path = path +
"/" + direntlist[i].name().ToString();
172 child_path, direntlist[i], catalog_mgr));
173 weight += children[i].weight;
190 template <
class CatalogMgrT>
193 if (!IsCatalog() && IsDirectory()) {
194 for (
unsigned i = 0; i < children.size(); ++i) {
195 weight += children[i].weight;
202 #endif // CVMFS_CATALOG_BALANCER_IMPL_H_
ShortString< kDefaultMaxName, 1 > NameString
const std::vector< CatalogT * > & GetCatalogs() const
assert((mem||(size==0))&&"Out Of Memory")
bool LookupPath(const PathString &path, const LookupOptions options, DirectoryEntry *entry)
CatalogMgrT::catalog_t catalog_t
const unsigned balance_weight_
const unsigned kLookupDefault
catalog::WritableCatalogManager * catalog_mgr_
std::vector< DirectoryEntry > DirectoryEntryList
bool is_new_nested_catalog
upload::Spooler * spooler_
const unsigned min_weight_
void HashMem(const unsigned char *buffer, const unsigned buffer_size, Any *any_digest)
ShortString< kDefaultMaxPath, 0 > PathString
bool CompressMem2Mem(const void *buf, const int64_t size, void **out_buf, uint64_t *out_size)
void ExtractChildren(CatalogMgrT *catalog_mgr)
std::vector< VirtualNode > children
void AddFile(const DirectoryEntryBase &entry, const XattrList &xattrs, const std::string &parent_directory)
void CreateNestedCatalog(const std::string &mountpoint)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)