CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
history::SqliteHistory Class Reference

#include <history_sqlite.h>

Inheritance diagram for history::SqliteHistory:
Collaboration diagram for history::SqliteHistory:

Public Member Functions

virtual ~SqliteHistory ()
 
bool IsWritable () const
 
unsigned GetNumberOfTags () const
 
bool BeginTransaction () const
 
bool CommitTransaction () const
 
virtual bool Vacuum ()
 
bool SetPreviousRevision (const shash::Any &history_hash)
 
shash::Any previous_revision () const
 
bool Insert (const Tag &tag)
 
bool Remove (const std::string &name)
 
bool Exists (const std::string &name) const
 
bool GetByName (const std::string &name, Tag *tag) const
 
bool GetByDate (const time_t timestamp, Tag *tag) const
 
bool List (std::vector< Tag > *tags) const
 
virtual bool GetBranchHead (const std::string &branch_name, Tag *tag) const
 
virtual bool ExistsBranch (const std::string &branch_name) const
 
virtual bool InsertBranch (const Branch &branch)
 
virtual bool PruneBranches ()
 
virtual bool ListBranches (std::vector< Branch > *branches) const
 
bool ListRecycleBin (std::vector< shash::Any > *hashes) const
 
bool EmptyRecycleBin ()
 
bool Rollback (const Tag &updated_target_tag)
 
bool ListTagsAffectedByRollback (const std::string &target_tag_name, std::vector< Tag > *tags) const
 
bool GetHashes (std::vector< shash::Any > *hashes) const
 
void TakeDatabaseFileOwnership ()
 
void DropDatabaseFileOwnership ()
 
bool OwnsDatabaseFile () const
 
std::string filename () const
 
- Public Member Functions inherited from history::History
virtual ~History ()
 
const std::string & fqrn () const
 

Static Public Member Functions

static SqliteHistoryOpen (const std::string &file_name)
 
static SqliteHistoryOpenWritable (const std::string &file_name)
 
static SqliteHistoryCreate (const std::string &file_name, const std::string &fqrn)
 

Protected Member Functions

bool OpenDatabase (const std::string &file_name, const bool read_write)
 
bool CreateDatabase (const std::string &file_name, const std::string &fqrn)
 
void PrepareQueries ()
 
- Protected Member Functions inherited from history::History
void set_fqrn (const std::string &fqrn)
 

Static Protected Member Functions

static SqliteHistoryOpen (const std::string &file_name, const bool read_write)
 

Static Protected Attributes

static const std::string kPreviousRevisionKey = "previous_revision"
 

Private Member Functions

template<class SqlListingT >
bool RunListing (std::vector< Tag > *list, SqlListingT *sql) const
 

Private Attributes

UniquePtr< HistoryDatabasedatabase_
 
UniquePtr< SqlInsertTaginsert_tag_
 
UniquePtr< SqlRemoveTagremove_tag_
 
UniquePtr< SqlFindTagfind_tag_
 
UniquePtr< SqlFindTagByDatefind_tag_by_date_
 
UniquePtr< SqlCountTagscount_tags_
 
UniquePtr< SqlListTagslist_tags_
 
UniquePtr< SqlGetHashesget_hashes_
 
UniquePtr< SqlRollbackTagrollback_tag_
 
UniquePtr< SqlListRollbackTagslist_rollback_tags_
 
UniquePtr< SqlListBrancheslist_branches_
 
UniquePtr< SqlInsertBranchinsert_branch_
 
UniquePtr< SqlFindBranchHeadfind_branch_head_
 
UniquePtr< SqlRecycleBinListrecycle_list_
 
UniquePtr< SqlRecycleBinFlushrecycle_empty_
 

Detailed Description

This class wraps the history of a repository, i.e. it contains a database of named snapshots or tags. Internally it uses the HistoryDatabase class to store those tags in an SQLite file.

Definition at line 25 of file history_sqlite.h.

Constructor & Destructor Documentation

virtual history::SqliteHistory::~SqliteHistory ( )
inlinevirtual

Definition at line 30 of file history_sqlite.h.

Member Function Documentation

bool history::SqliteHistory::BeginTransaction ( ) const
virtual

Opens a new database transaction in the underlying SQLite database This can greatly improve performance when used before inserting or removing multiple tags.

Implements history::History.

Definition at line 128 of file history_sqlite.cc.

bool history::SqliteHistory::CommitTransaction ( ) const
virtual

Closes a transaction (see BeginTransaction())

Implements history::History.

Definition at line 133 of file history_sqlite.cc.

SqliteHistory * history::SqliteHistory::Create ( const std::string &  file_name,
const std::string &  fqrn 
)
static

Creates an empty History database. Since a History object is always associated to a specific repository, one needs to specify the fully qualified repository name (FQRN) on creation of the History database. Note: pointer ownership is assumed to be retained by the caller.

Parameters
file_namethe path of the new history file.
fqrnthe FQRN of the repository containing this History
Returns
pointer to empty History object or NULL on error

Definition at line 43 of file history_sqlite.cc.

Referenced by publish::CreateRootObjects(), publish::DownloadRootObjects(), swissknife::Assistant::GetHistory(), and swissknife::CommandTag::GetHistory().

Here is the call graph for this function:

Here is the caller graph for this function:

bool history::SqliteHistory::CreateDatabase ( const std::string &  file_name,
const std::string &  fqrn 
)
protected

Definition at line 84 of file history_sqlite.cc.

Referenced by Create().

Here is the call graph for this function:

Here is the caller graph for this function:

void history::SqliteHistory::DropDatabaseFileOwnership ( )
virtual

Implements history::History.

Definition at line 469 of file history_sqlite.cc.

Referenced by publish::PushHistory().

Here is the call graph for this function:

Here is the caller graph for this function:

bool history::SqliteHistory::EmptyRecycleBin ( )
virtual

Implements history::History.

Definition at line 366 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::Exists ( const std::string &  name) const
virtual

Implements history::History.

Definition at line 195 of file history_sqlite.cc.

Referenced by publish::EditTags().

Here is the caller graph for this function:

bool history::SqliteHistory::ExistsBranch ( const std::string &  branch_name) const
virtual

Implements history::History.

Definition at line 269 of file history_sqlite.cc.

std::string history::SqliteHistory::filename ( ) const
inline

Definition at line 148 of file history_sqlite.h.

Referenced by publish::PushHistory().

Here is the caller graph for this function:

bool history::SqliteHistory::GetBranchHead ( const std::string &  branch_name,
Tag tag 
) const
virtual

Implements history::History.

Definition at line 252 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::GetByDate ( const time_t  timestamp,
Tag tag 
) const
virtual

Implements history::History.

Definition at line 216 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::GetByName ( const std::string &  name,
Tag tag 
) const
virtual

Implements history::History.

Definition at line 201 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::GetHashes ( std::vector< shash::Any > *  hashes) const
virtual

Provides a list of all referenced catalog hashes in this History. The hashes will be ordered by their associated revision number in ascending order.

Parameters
hashespointer to the result vector to be filled

Implements history::History.

Definition at line 451 of file history_sqlite.cc.

Here is the call graph for this function:

unsigned history::SqliteHistory::GetNumberOfTags ( ) const
virtual

Implements history::History.

Definition at line 158 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::Insert ( const Tag tag)
virtual

Implements history::History.

Definition at line 170 of file history_sqlite.cc.

Referenced by publish::EditTags().

Here is the call graph for this function:

Here is the caller graph for this function:

bool history::SqliteHistory::InsertBranch ( const Branch branch)
virtual

Implements history::History.

Definition at line 281 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::IsWritable ( ) const
virtual

Implements history::History.

Definition at line 153 of file history_sqlite.cc.

Referenced by Open().

Here is the call graph for this function:

Here is the caller graph for this function:

bool history::SqliteHistory::List ( std::vector< Tag > *  tags) const
virtual

Implements history::History.

Definition at line 233 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::ListBranches ( std::vector< Branch > *  branches) const
virtual

Implements history::History.

Definition at line 340 of file history_sqlite.cc.

bool history::SqliteHistory::ListRecycleBin ( std::vector< shash::Any > *  hashes) const
virtual

The recycle bin operations are deprecated, only emptying and listing are preserved for migration and testing.

Implements history::History.

Definition at line 349 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::ListTagsAffectedByRollback ( const std::string &  target_tag_name,
std::vector< Tag > *  tags 
) const
virtual

Lists the tags that would be deleted by a rollback to the tag specified.

Note: This doesn't change the database but is mainly used for sanity checks and user output.

Parameters
target_tag_namethe tag name for the planned rollback
tagspointer to the result tag list to be filled
Returns
true on success

Implements history::History.

Definition at line 428 of file history_sqlite.cc.

Here is the call graph for this function:

SqliteHistory * history::SqliteHistory::Open ( const std::string &  file_name)
static

Opens an available history database file in read-only mode and returns a pointer to a History object wrapping this database. Note: The caller is assumed to retain ownership of the pointer and the history database is closed on deletion of the History object.

Parameters
file_namethe path to the history SQLite file to be opened
Returns
pointer to History object or NULL on error

Definition at line 14 of file history_sqlite.cc.

Referenced by MountPoint::DetermineRootHash(), swissknife::Assistant::GetHistory(), swissknife::CommandTag::GetHistory(), swissknife::CommandPull::Main(), and swissknife::CommandCheck::Main().

Here is the call graph for this function:

Here is the caller graph for this function:

SqliteHistory * history::SqliteHistory::Open ( const std::string &  file_name,
const bool  read_write 
)
staticprotected

Definition at line 26 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::OpenDatabase ( const std::string &  file_name,
const bool  read_write 
)
protected

Definition at line 58 of file history_sqlite.cc.

Referenced by Open().

Here is the call graph for this function:

Here is the caller graph for this function:

SqliteHistory * history::SqliteHistory::OpenWritable ( const std::string &  file_name)
static

Same as SqliteHistory::Open(), but opens the history database file in read/write mode. This allows to use the modifying methods of the History object.

Parameters
file_namethe path to the history SQLite file to be opened
Returns
pointer to History object or NULL on error

Definition at line 20 of file history_sqlite.cc.

Referenced by publish::DownloadRootObjects(), swissknife::Assistant::GetHistory(), swissknife::CommandTag::GetHistory(), publish::PushHistory(), and swissknife::CommandMigrate::UpdateUndoTags().

Here is the call graph for this function:

Here is the caller graph for this function:

bool history::SqliteHistory::OwnsDatabaseFile ( ) const
inlinevirtual

Implements history::History.

Definition at line 145 of file history_sqlite.h.

void history::SqliteHistory::PrepareQueries ( )
protected

Definition at line 102 of file history_sqlite.cc.

Here is the call graph for this function:

shash::Any history::SqliteHistory::previous_revision ( ) const
virtual

Implements history::History.

Definition at line 145 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::PruneBranches ( )
virtual

When removing tags, branches can become abandoned. Remove abandoned branches and redirect the parent pointer of their child branches.

Implements history::History.

Definition at line 291 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::Remove ( const std::string &  name)
virtual

Implements history::History.

Definition at line 180 of file history_sqlite.cc.

Referenced by publish::EditTags().

Here is the call graph for this function:

Here is the caller graph for this function:

bool history::SqliteHistory::Rollback ( const Tag updated_target_tag)
virtual

Rolls back the history to the provided target tag and deletes all tags of the containing channel in between.

Note: this assumes that the provided target tag was already updated with the republished root catalog information.

Parameters
updated_target_tagthe tag to be rolled back to (updated: see Note)
Returns
true on success

Implements history::History.

Definition at line 375 of file history_sqlite.cc.

Here is the call graph for this function:

template<class SqlListingT >
bool history::SqliteHistory::RunListing ( std::vector< Tag > *  list,
SqlListingT *  sql 
) const
private

Definition at line 240 of file history_sqlite.cc.

Here is the call graph for this function:

bool history::SqliteHistory::SetPreviousRevision ( const shash::Any history_hash)
virtual

Sets the internal pointer to the previous revision of this History file. Note: This must be handled by the user code.

Parameters
history_hashthe content hash of the previous revision

Implements history::History.

Definition at line 138 of file history_sqlite.cc.

Referenced by publish::PushHistory().

Here is the call graph for this function:

Here is the caller graph for this function:

void history::SqliteHistory::TakeDatabaseFileOwnership ( )
virtual

Implements history::History.

Definition at line 463 of file history_sqlite.cc.

Referenced by publish::DownloadRootObjects(), and publish::PushHistory().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool history::SqliteHistory::Vacuum ( )
inlinevirtual

Implements history::History.

Definition at line 81 of file history_sqlite.h.

Member Data Documentation

UniquePtr<SqlCountTags> history::SqliteHistory::count_tags_
private

Definition at line 168 of file history_sqlite.h.

UniquePtr<HistoryDatabase> history::SqliteHistory::database_
private

Definition at line 162 of file history_sqlite.h.

Referenced by filename(), OwnsDatabaseFile(), and Vacuum().

UniquePtr<SqlFindBranchHead> history::SqliteHistory::find_branch_head_
private

Definition at line 175 of file history_sqlite.h.

UniquePtr<SqlFindTag> history::SqliteHistory::find_tag_
private

Definition at line 166 of file history_sqlite.h.

UniquePtr<SqlFindTagByDate> history::SqliteHistory::find_tag_by_date_
private

Definition at line 167 of file history_sqlite.h.

UniquePtr<SqlGetHashes> history::SqliteHistory::get_hashes_
private

Definition at line 170 of file history_sqlite.h.

UniquePtr<SqlInsertBranch> history::SqliteHistory::insert_branch_
private

Definition at line 174 of file history_sqlite.h.

UniquePtr<SqlInsertTag> history::SqliteHistory::insert_tag_
private

Definition at line 164 of file history_sqlite.h.

const std::string history::SqliteHistory::kPreviousRevisionKey = "previous_revision"
staticprotected

Definition at line 27 of file history_sqlite.h.

UniquePtr<SqlListBranches> history::SqliteHistory::list_branches_
private

Definition at line 173 of file history_sqlite.h.

UniquePtr<SqlListRollbackTags> history::SqliteHistory::list_rollback_tags_
private

Definition at line 172 of file history_sqlite.h.

UniquePtr<SqlListTags> history::SqliteHistory::list_tags_
private

Definition at line 169 of file history_sqlite.h.

UniquePtr<SqlRecycleBinFlush> history::SqliteHistory::recycle_empty_
private

Definition at line 177 of file history_sqlite.h.

UniquePtr<SqlRecycleBinList> history::SqliteHistory::recycle_list_
private

Definition at line 176 of file history_sqlite.h.

UniquePtr<SqlRemoveTag> history::SqliteHistory::remove_tag_
private

Definition at line 165 of file history_sqlite.h.

UniquePtr<SqlRollbackTag> history::SqliteHistory::rollback_tag_
private

Definition at line 171 of file history_sqlite.h.


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