CernVM-FS
2.12.0
|
#include <catalog_rw.h>
Public Member Functions | |
WritableCatalog (const std::string &path, const shash::Any &catalog_hash, Catalog *parent, const bool is_not_root=false) | |
virtual | ~WritableCatalog () |
void | Transaction () |
void | Commit () |
bool | IsDirty () const |
bool | IsWritable () const |
uint32_t | GetMaxLinkId () const |
void | AddEntry (const DirectoryEntry &entry, const XattrList &xattr, const std::string &entry_path, const std::string &parent_path) |
void | TouchEntry (const DirectoryEntryBase &entry, const XattrList &xattrs, const shash::Md5 &path_hash) |
void | TouchEntry (const DirectoryEntryBase &entry, const XattrList &xattrs, const std::string &path) |
void | RemoveEntry (const std::string &entry_path) |
void | IncLinkcount (const std::string &path_within_group, const int delta) |
void | AddFileChunk (const std::string &entry_path, const FileChunk &chunk) |
void | RemoveFileChunks (const std::string &entry_path) |
void | Partition (WritableCatalog *new_nested_catalog) |
void | MergeIntoParent () |
void | RemoveFromParent () |
void | InsertNestedCatalog (const std::string &mountpoint, Catalog *attached_reference, const shash::Any content_hash, const uint64_t size) |
void | InsertBindMountpoint (const std::string &mountpoint, const shash::Any content_hash, const uint64_t size) |
void | UpdateNestedCatalog (const std::string &path, const shash::Any &hash, const uint64_t size, const DeltaCounters &child_counters) |
void | RemoveNestedCatalog (const std::string &mountpoint, Catalog **attached_reference) |
void | RemoveBindMountpoint (const std::string &mountpoint) |
void | UpdateLastModified () |
void | IncrementRevision () |
void | SetRevision (const uint64_t new_revision) |
void | SetBranch (const std::string &branch_name) |
void | SetPreviousRevision (const shash::Any &hash) |
void | SetTTL (const uint64_t new_ttl) |
bool | SetVOMSAuthz (const std::string &voms_authz) |
Public Member Functions inherited from catalog::Catalog | |
Catalog (const PathString &mountpoint, const shash::Any &catalog_hash, Catalog *parent, const bool is_nested=false) | |
virtual | ~Catalog () |
bool | OpenDatabase (const std::string &db_path) |
bool | LookupPath (const PathString &path, DirectoryEntry *dirent) const |
bool | LookupRawSymlink (const PathString &path, LinkString *raw_symlink) const |
bool | LookupXattrsPath (const PathString &path, XattrList *xattrs) const |
bool | ListingPath (const PathString &path, DirectoryEntryList *listing, const bool expand_symlink=true) const |
bool | ListingPathStat (const PathString &path, StatEntryList *listing) const |
bool | AllChunksBegin () |
bool | AllChunksNext (shash::Any *hash, zlib::Algorithms *compression_alg) |
bool | AllChunksEnd () |
bool | ListPathChunks (const PathString &path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks) const |
CatalogList | GetChildren () const |
Catalog * | FindSubtree (const PathString &path) const |
Catalog * | FindChild (const PathString &mountpoint) const |
void | AddChild (Catalog *child) |
void | RemoveChild (Catalog *child) |
const HashVector & | GetReferencedObjects () const |
void | TakeDatabaseFileOwnership () |
void | DropDatabaseFileOwnership () |
bool | OwnsDatabaseFile () const |
uint64_t | GetTTL () const |
bool | HasExplicitTTL () const |
uint64_t | GetRevision () const |
bool | GetVOMSAuthz (std::string *authz) const |
uint64_t | GetLastModified () const |
uint64_t | GetNumEntries () const |
uint64_t | GetNumChunks () const |
shash::Any | GetPreviousRevision () const |
const Counters & | GetCounters () const |
std::string | PrintMemStatistics () const |
float | schema () const |
PathString | mountpoint () const |
Catalog * | parent () const |
uint64_t | max_row_id () const |
InodeRange | inode_range () const |
void | set_inode_range (const InodeRange value) |
std::string | database_path () const |
PathString | root_prefix () const |
shash::Any | hash () const |
bool | volatile_flag () const |
uint64_t | revision () const |
bool | IsInitialized () const |
bool | IsRoot () const |
bool | IsAutogenerated () const |
bool | HasParent () const |
const NestedCatalogList & | ListNestedCatalogs () const |
const NestedCatalogList | ListOwnNestedCatalogs () const |
bool | FindNested (const PathString &mountpoint, shash::Any *hash, uint64_t *size) const |
void | SetInodeAnnotation (InodeAnnotation *new_annotation) |
inode_t | GetMangledInode (const uint64_t row_id, const uint64_t hardlink_group) const |
void | SetOwnerMaps (const OwnerMap *uid_map, const OwnerMap *gid_map) |
uint64_t | MapUid (const uint64_t uid) const |
uint64_t | MapGid (const uint64_t gid) const |
Static Public Member Functions | |
static WritableCatalog * | AttachFreely (const std::string &root_path, const std::string &file, const shash::Any &catalog_hash, Catalog *parent=NULL, const bool is_not_root=false) |
Static Public Member Functions inherited from catalog::Catalog | |
static Catalog * | AttachFreely (const std::string &imaginary_mountpoint, const std::string &file, const shash::Any &catalog_hash, Catalog *parent=NULL, const bool is_nested=false) |
Protected Member Functions | |
CatalogDatabase::OpenMode | DatabaseOpenMode () const |
void | UpdateEntry (const DirectoryEntry &entry, const shash::Md5 &path_hash) |
void | UpdateEntry (const DirectoryEntry &entry, const std::string &path) |
void | AddEntry (const DirectoryEntry &entry, const XattrList &xattrs, const std::string &path) |
void | InitPreparedStatements () |
void | FinalizePreparedStatements () |
WritableCatalog * | GetWritableParent () const |
int | dirty_children () const |
void | set_dirty_children (const int count) |
int | DecrementDirtyChildren () |
Protected Member Functions inherited from catalog::Catalog | |
bool | InitStandalone (const std::string &database_file) |
bool | ReadCatalogCounters () |
void | FinalizePreparedStatements () |
Counters & | GetWritableCounters () |
const CatalogDatabase & | database () const |
CatalogDatabase & | database () |
void | set_parent (Catalog *catalog) |
void | ResetNestedCatalogCacheUnprotected () |
bool | LookupMd5Path (const shash::Md5 &md5path, DirectoryEntry *dirent) const |
Static Protected Attributes | |
static const double | kMaximalFreePageRatio = 0.20 |
static const double | kMaximalRowIdWasteRatio = 0.25 |
Private Member Functions | |
void | SetDirty () |
void | MakeTransitionPoint (const std::string &mountpoint) |
void | MakeNestedRoot () |
void | MoveToNested (const std::string &dir_structure_root, WritableCatalog *new_nested_catalog, std::vector< std::string > *grand_child_mountpoints) |
void | MoveToNestedRecursively (const std::string dir_structure_root, WritableCatalog *new_nested_catalog, std::vector< std::string > *grand_child_mountpoints) |
void | MoveCatalogsToNested (const std::vector< std::string > &nested_catalogs, WritableCatalog *new_nested_catalog) |
void | MoveFileChunksToNested (const std::string &full_path, const shash::Algorithms algorithm, WritableCatalog *new_nested_catalog) |
void | CopyToParent () |
void | CopyCatalogsToParent () |
void | UpdateCounters () |
void | VacuumDatabaseIfNecessary () |
Friends | |
class | WritableCatalogManager |
class | swissknife::CommandMigrate |
class | VirtualCatalog |
Additional Inherited Members | |
Public Types inherited from catalog::Catalog | |
typedef std::vector< shash::Any > | HashVector |
typedef std::vector < NestedCatalog > | NestedCatalogList |
Static Public Attributes inherited from catalog::Catalog | |
static const uint64_t | kDefaultTTL = 240 |
Protected Types inherited from catalog::Catalog | |
typedef std::map< uint64_t, inode_t > | HardlinkGroupMap |
Protected Attributes inherited from catalog::Catalog | |
HardlinkGroupMap | hardlink_groups_ |
pthread_mutex_t * | lock_ |
Definition at line 36 of file catalog_rw.h.
catalog::WritableCatalog::WritableCatalog | ( | const std::string & | path, |
const shash::Any & | catalog_hash, | ||
Catalog * | parent, | ||
const bool | is_not_root = false |
||
) |
Definition at line 26 of file catalog_rw.cc.
Referenced by AttachFreely().
|
virtual |
void catalog::WritableCatalog::AddEntry | ( | const DirectoryEntry & | entry, |
const XattrList & | xattr, | ||
const std::string & | entry_path, | ||
const std::string & | parent_path | ||
) |
Referenced by catalog::WritableCatalogManager::AddDirectory(), AddEntry(), catalog::WritableCatalogManager::AddFile(), catalog::WritableCatalogManager::AddHardlinkGroup(), and MoveToNestedRecursively().
|
inlineprotected |
void catalog::WritableCatalog::AddFileChunk | ( | const std::string & | entry_path, |
const FileChunk & | chunk | ||
) |
Definition at line 264 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::AddChunkedFile(), catalog::WritableCatalogManager::AddHardlinkGroup(), and MoveFileChunksToNested().
|
static |
Definition at line 49 of file catalog_rw.cc.
Referenced by swissknife::CommandMigrate::MigrationWorker_20x::CreateNewEmptyCatalog(), swissknife::Assistant::GetCatalog(), and swissknife::CommandTag::GetCatalog().
void catalog::WritableCatalog::Commit | ( | ) |
Definition at line 80 of file catalog_rw.cc.
Referenced by swissknife::CommandMigrate::MigrationWorker_20x::CommitDatabaseTransaction(), CopyToParent(), and catalog::WritableCatalogManager::FinalizeCatalog().
|
private |
Definition at line 679 of file catalog_rw.cc.
Referenced by MergeIntoParent().
|
private |
Definition at line 698 of file catalog_rw.cc.
Referenced by MergeIntoParent().
|
inlineprotectedvirtual |
Specifies the SQLite open flags. Overwritten by r/w catalog.
Reimplemented from catalog::Catalog.
Definition at line 113 of file catalog_rw.h.
|
inlineprotected |
Definition at line 146 of file catalog_rw.h.
Referenced by catalog::WritableCatalogManager::CatalogUploadCallback().
|
inlineprotected |
Definition at line 142 of file catalog_rw.h.
|
protected |
Definition at line 106 of file catalog_rw.cc.
Referenced by ~WritableCatalog().
uint32_t catalog::WritableCatalog::GetMaxLinkId | ( | ) | const |
Find out the maximal hardlink group id in this catalog.
Definition at line 124 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::AddHardlinkGroup(), and CopyToParent().
|
inlineprotected |
Definition at line 136 of file catalog_rw.h.
Referenced by catalog::WritableCatalogManager::CatalogUploadCallback(), CopyCatalogsToParent(), CopyToParent(), MergeIntoParent(), RemoveFromParent(), and catalog::WritableCatalogManager::SnapshotCatalogsSerialized().
void catalog::WritableCatalog::IncLinkcount | ( | const std::string & | path_within_group, |
const int | delta | ||
) |
Definition at line 208 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::ShrinkHardlinkGroup().
void catalog::WritableCatalog::IncrementRevision | ( | ) |
Increments the revision of the catalog in the database.
Definition at line 324 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::FinalizeCatalog(), and swissknife::CommandMigrate::AbstractMigrationWorker< DerivedT >::UpdateCatalogMetadata().
|
protectedvirtual |
InitPreparedStatement uses polymorphism in case of a r/w catalog. FinalizePreparedStatements is called in the destructor where polymorphism does not work any more and has to be called both in the WritableCatalog and the Catalog destructor
Reimplemented from catalog::Catalog.
Definition at line 89 of file catalog_rw.cc.
void catalog::WritableCatalog::InsertBindMountpoint | ( | const std::string & | mountpoint, |
const shash::Any | content_hash, | ||
const uint64_t | size | ||
) |
Registers a snapshot in /.cvmfs/snapshots. Note that bind mountpoints are not universally handled: in Partition and MergeIntoParent, bind mountpoint handling is missing!
Definition at line 535 of file catalog_rw.cc.
Referenced by catalog::VirtualCatalog::InsertSnapshot().
void catalog::WritableCatalog::InsertNestedCatalog | ( | const std::string & | mountpoint, |
Catalog * | attached_reference, | ||
const shash::Any | content_hash, | ||
const uint64_t | size | ||
) |
Insert a nested catalog reference into this catalog. The attached catalog object of this mountpoint can be specified (optional) This way, the in-memory representation of the catalog tree is updated, too
mountpoint | the path to the catalog to add a reference to |
attached_reference | can contain a reference to the attached catalog object of mountpoint |
content_hash | can be set to safe a content hash together with the reference |
Definition at line 502 of file catalog_rw.cc.
Referenced by CopyCatalogsToParent(), catalog::WritableCatalogManager::CreateNestedCatalog(), MoveCatalogsToNested(), and catalog::WritableCatalogManager::SwapNestedCatalog().
|
inline |
Definition at line 57 of file catalog_rw.h.
Referenced by catalog::WritableCatalogManager::GetModifiedCatalogLeafsRecursively(), catalog::WritableCatalogManager::GetModifiedCatalogsRecursively(), and swissknife::CommandMigrate::MigrationWorker_20x::MigrateFileMetadata().
|
inlinevirtual |
Reimplemented from catalog::Catalog.
Definition at line 58 of file catalog_rw.h.
|
private |
Definition at line 395 of file catalog_rw.cc.
Referenced by Partition().
|
private |
Definition at line 380 of file catalog_rw.cc.
Referenced by Partition().
void catalog::WritableCatalog::MergeIntoParent | ( | ) |
Definition at line 646 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::RemoveNestedCatalog().
|
private |
Definition at line 456 of file catalog_rw.cc.
Referenced by Partition().
|
private |
Definition at line 477 of file catalog_rw.cc.
Referenced by MoveToNestedRecursively().
|
inlineprivate |
Definition at line 177 of file catalog_rw.h.
Referenced by Partition().
|
private |
Definition at line 407 of file catalog_rw.cc.
Referenced by MoveToNested().
void catalog::WritableCatalog::Partition | ( | WritableCatalog * | new_nested_catalog | ) |
Moves a subtree from this catalog into a just created nested catalog.
Definition at line 360 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::CreateNestedCatalog().
void catalog::WritableCatalog::RemoveBindMountpoint | ( | const std::string & | mountpoint | ) |
Unregisters a snapshot from /.cvmfs/snapshots. Note that bind mountpoints are not universally handled: in Partition and MergeIntoParent, bind mountpoint handling is missing!
Definition at line 597 of file catalog_rw.cc.
Referenced by catalog::VirtualCatalog::RemoveSnapshot().
void catalog::WritableCatalog::RemoveEntry | ( | const std::string & | entry_path | ) |
Removes the specified entry from the catalog. Note: removing a directory which is non-empty results in dangling entries. (this should be treated in upper layers)
entry_path | the full path of the DirectoryEntry to delete |
Definition at line 184 of file catalog_rw.cc.
Referenced by CopyToParent(), catalog::WritableCatalogManager::FixWeight(), MoveToNestedRecursively(), catalog::WritableCatalogManager::RemoveDirectory(), and catalog::WritableCatalogManager::RemoveFile().
void catalog::WritableCatalog::RemoveFileChunks | ( | const std::string & | entry_path | ) |
Removes the file chunks for a given file path
entry_path | the file path to clear from it's file chunks |
Definition at line 291 of file catalog_rw.cc.
Referenced by RemoveEntry().
void catalog::WritableCatalog::RemoveFromParent | ( | ) |
Definition at line 667 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::RemoveNestedCatalog().
void catalog::WritableCatalog::RemoveNestedCatalog | ( | const std::string & | mountpoint, |
Catalog ** | attached_reference | ||
) |
Remove a nested catalog reference from the database. If the catalog 'mountpoint' is currently attached as a child, it will be removed, too (but not detached).
[in] | mountpoint | the mountpoint of the nested catalog to dereference in the database |
[out] | attached_reference | is set to the object of the attached child or to NULL |
Definition at line 561 of file catalog_rw.cc.
Referenced by MergeIntoParent(), MoveCatalogsToNested(), RemoveFromParent(), and catalog::WritableCatalogManager::SwapNestedCatalog().
|
inlineprotected |
Definition at line 143 of file catalog_rw.h.
Referenced by catalog::WritableCatalogManager::GetModifiedCatalogLeafsRecursively().
void catalog::WritableCatalog::SetBranch | ( | const std::string & | branch_name | ) |
|
inlineprivate |
Definition at line 168 of file catalog_rw.h.
Referenced by AddFileChunk(), catalog::WritableCatalogManager::Commit(), CopyToParent(), IncLinkcount(), RemoveEntry(), TouchEntry(), UpdateEntry(), and UpdateNestedCatalog().
void catalog::WritableCatalog::SetPreviousRevision | ( | const shash::Any & | hash | ) |
Sets the content hash of the previous catalog revision.
Definition at line 352 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::FinalizeCatalog(), and swissknife::CommandMigrate::AbstractMigrationWorker< DerivedT >::UpdateCatalogMetadata().
void catalog::WritableCatalog::SetRevision | ( | const uint64_t | new_revision | ) |
Definition at line 329 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::Commit(), and IncrementRevision().
void catalog::WritableCatalog::SetTTL | ( | const uint64_t | new_ttl | ) |
bool catalog::WritableCatalog::SetVOMSAuthz | ( | const std::string & | voms_authz | ) |
void catalog::WritableCatalog::TouchEntry | ( | const DirectoryEntryBase & | entry, |
const XattrList & | xattrs, | ||
const shash::Md5 & | path_hash | ||
) |
Definition at line 224 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::SwapNestedCatalog(), catalog::WritableCatalogManager::TouchDirectory(), and TouchEntry().
|
inline |
void catalog::WritableCatalog::Transaction | ( | ) |
Definition at line 72 of file catalog_rw.cc.
Referenced by SetDirty(), and swissknife::CommandMigrate::MigrationWorker_20x::StartDatabaseTransaction().
|
private |
Writes delta_counters_ to the database.
Definition at line 765 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::FinalizeCatalog().
|
protected |
Definition at line 252 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::AddDirectory(), CopyToParent(), catalog::VirtualCatalog::CreateBaseDirectory(), catalog::VirtualCatalog::InsertSnapshot(), MakeNestedRoot(), MakeTransitionPoint(), catalog::WritableCatalogManager::RemoveDirectory(), catalog::WritableCatalogManager::SwapNestedCatalog(), and UpdateEntry().
|
inlineprotected |
void catalog::WritableCatalog::UpdateLastModified | ( | ) |
Sets the last modified time stamp of this catalog to current time.
Definition at line 316 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::FinalizeCatalog(), and swissknife::CommandMigrate::AbstractMigrationWorker< DerivedT >::UpdateCatalogMetadata().
void catalog::WritableCatalog::UpdateNestedCatalog | ( | const std::string & | path, |
const shash::Any & | hash, | ||
const uint64_t | size, | ||
const DeltaCounters & | child_counters | ||
) |
Updates the link to a nested catalog in the database.
path | the path of the nested catalog to update |
hash | the hash to set the given nested catalog link to |
size | the uncompressed catalog database file size |
child_counters | the statistics counters of the nested catalog |
Definition at line 620 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::CatalogUploadCallback(), and catalog::WritableCatalogManager::SnapshotCatalogsSerialized().
|
private |
Checks if the database of this catalogs needs cleanup and defragments it if necessary
Definition at line 776 of file catalog_rw.cc.
Referenced by catalog::WritableCatalogManager::FinalizeCatalog().
|
friend |
Definition at line 38 of file catalog_rw.h.
|
friend |
Definition at line 39 of file catalog_rw.h.
|
friend |
Definition at line 37 of file catalog_rw.h.
|
private |
Definition at line 163 of file catalog_rw.h.
Referenced by AddFileChunk(), catalog::WritableCatalogManager::CatalogUploadCallback(), CopyCatalogsToParent(), InsertNestedCatalog(), MergeIntoParent(), Partition(), RemoveEntry(), RemoveFileChunks(), RemoveFromParent(), RemoveNestedCatalog(), catalog::WritableCatalogManager::SwapNestedCatalog(), TouchEntry(), UpdateCounters(), and UpdateNestedCatalog().
|
private |
Indicates if the catalog has been changed
Definition at line 161 of file catalog_rw.h.
Referenced by Commit(), CopyToParent(), IsDirty(), and SetDirty().
|
mutableprivate |
Definition at line 166 of file catalog_rw.h.
Referenced by DecrementDirtyChildren(), dirty_children(), set_dirty_children(), and WritableCatalog().
|
staticprotected |
Definition at line 110 of file catalog_rw.h.
Referenced by VacuumDatabaseIfNecessary().
|
staticprotected |
Definition at line 111 of file catalog_rw.h.
Referenced by VacuumDatabaseIfNecessary().
|
private |
Definition at line 155 of file catalog_rw.h.
Referenced by AddFileChunk(), FinalizePreparedStatements(), and InitPreparedStatements().
|
private |
Definition at line 157 of file catalog_rw.h.
Referenced by FinalizePreparedStatements(), InitPreparedStatements(), and RemoveFileChunks().
|
private |
Definition at line 156 of file catalog_rw.h.
Referenced by FinalizePreparedStatements(), InitPreparedStatements(), and RemoveFileChunks().
|
private |
Definition at line 159 of file catalog_rw.h.
Referenced by FinalizePreparedStatements(), IncLinkcount(), and InitPreparedStatements().
|
private |
Definition at line 151 of file catalog_rw.h.
Referenced by FinalizePreparedStatements(), and InitPreparedStatements().
|
private |
Definition at line 158 of file catalog_rw.h.
Referenced by FinalizePreparedStatements(), GetMaxLinkId(), and InitPreparedStatements().
|
private |
Definition at line 153 of file catalog_rw.h.
Referenced by FinalizePreparedStatements(), InitPreparedStatements(), and TouchEntry().
|
private |
Definition at line 152 of file catalog_rw.h.
Referenced by FinalizePreparedStatements(), InitPreparedStatements(), and RemoveEntry().
|
private |
Definition at line 154 of file catalog_rw.h.
Referenced by FinalizePreparedStatements(), InitPreparedStatements(), and UpdateEntry().