autotier
Automatic Tiering Fuse Filesystem
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Metadata Class Reference

File metadata to be stored in and retrieved from the RocksDB database. More...

#include <metadata.hpp>

Public Member Functions

 Metadata (void)
 Construct a new empty Metadata object. More...
 
 Metadata (const std::string &serialized)
 Construct a new Metadata object from serialized string. More...
 
 Metadata (const Metadata &other)
 Copy construct a new Metadata object. More...
 
Metadataoperator= (const Metadata &other)
 Copy assign a new Metadata object. More...
 
 Metadata (Metadata &&other)
 Move construct a new Metadata object. More...
 
Metadataoperator= (Metadata &&other)
 Move assign a new Metadata object. More...
 
 ~Metadata (void)=default
 Destroy the Metadata object. More...
 
 Metadata (std::string path, std::shared_ptr< rocksdb::DB > db, Tier *tptr=nullptr)
 Construct a new Metadata object. Try to retrieve data from db. If not found and tptr != nullptr, new metadata object is initialized and put into the database. If not found and tptr == nullptr, metadata is left undefined and not_found_ is set to true. More...
 
void update (std::string relative_path, std::shared_ptr< rocksdb::DB > db, std::string *old_key=nullptr)
 Put metadata into database with relative_path as the key. More...
 
void touch (void)
 Increment access_count_. More...
 
std::string tier_path (void) const
 Get path to tier root. More...
 
void tier_path (const std::string &path)
 Set path to tier root. More...
 
bool pinned (void) const
 Test if metadata has pinned flag set. More...
 
void pinned (bool val)
 Set pinned flag. More...
 
double popularity (void) const
 Get popularity. More...
 
bool not_found (void) const
 Test if metadata was found in database. More...
 
std::string dump_stats (void) const
 Return metadata as formatted string. More...
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize method for boost::serialize. More...
 

Private Attributes

uintmax_t access_count_ = 0
 Number of times the file was accessed since last tiering. Resets to 0 after each popularity calculation. More...
 
double popularity_ = MULTIPLIER * AVG_USAGE
 Moving average of file usage frequency in accesses per hour. Used to sort list of files to determine which tiers they belong in. More...
 
bool not_found_ = false
 Set to true when the file metadata could not be retrieved from the database. More...
 
bool pinned_ = false
 Flag to determine whether to ignore file while tiering. When true, the file stays in the tier it is in. More...
 
std::string tier_path_
 The backend path of the tier. This + relative path is the real location of the file. More...
 

Friends

class boost::serialization::access
 
class File
 
class MetadataViewer
 

Detailed Description

File metadata to be stored in and retrieved from the RocksDB database.

Constructor & Destructor Documentation

◆ Metadata() [1/5]

Metadata::Metadata ( void  )

Construct a new empty Metadata object.

◆ Metadata() [2/5]

Metadata::Metadata ( const std::string &  serialized)

Construct a new Metadata object from serialized string.

Parameters
serializedSerialized string representing Metadata object

◆ Metadata() [3/5]

Metadata::Metadata ( const Metadata other)

Copy construct a new Metadata object.

Parameters
other

◆ Metadata() [4/5]

Metadata::Metadata ( Metadata &&  other)

Move construct a new Metadata object.

Parameters
other

◆ ~Metadata()

Metadata::~Metadata ( void  )
default

Destroy the Metadata object.

◆ Metadata() [5/5]

Metadata::Metadata ( std::string  path,
std::shared_ptr< rocksdb::DB >  db,
Tier tptr = nullptr 
)

Construct a new Metadata object. Try to retrieve data from db. If not found and tptr != nullptr, new metadata object is initialized and put into the database. If not found and tptr == nullptr, metadata is left undefined and not_found_ is set to true.

Parameters
path
db
tptr

Member Function Documentation

◆ dump_stats()

std::string Metadata::dump_stats ( void  ) const

Return metadata as formatted string.

Returns
std::string

◆ not_found()

bool Metadata::not_found ( void  ) const

Test if metadata was found in database.

Returns
true metadata was not found
false metadata was found

◆ operator=() [1/2]

Metadata & Metadata::operator= ( const Metadata other)

Copy assign a new Metadata object.

Parameters
other
Returns
Metadata&

◆ operator=() [2/2]

Metadata & Metadata::operator= ( Metadata &&  other)

Move assign a new Metadata object.

Parameters
other
Returns
Metadata&

◆ pinned() [1/2]

void Metadata::pinned ( bool  val)

Set pinned flag.

Parameters
val

◆ pinned() [2/2]

bool Metadata::pinned ( void  ) const

Test if metadata has pinned flag set.

Returns
true File corresponding to metadata is pinned
false File corresponding to metadata is not pinned

◆ popularity()

double Metadata::popularity ( void  ) const

Get popularity.

Returns
double Popularity of file

◆ serialize()

template<class Archive >
void Metadata::serialize ( Archive &  ar,
const unsigned int  version 
)
inlineprivate

Serialize method for boost::serialize.

Template Parameters
ArchiveTemplate type
Parameters
arInternal boost::serialize object
versionboost::serialize version (unused)

◆ tier_path() [1/2]

void Metadata::tier_path ( const std::string &  path)

Set path to tier root.

Parameters
path

◆ tier_path() [2/2]

std::string Metadata::tier_path ( void  ) const

Get path to tier root.

Returns
std::string

◆ touch()

void Metadata::touch ( void  )

Increment access_count_.

◆ update()

void Metadata::update ( std::string  relative_path,
std::shared_ptr< rocksdb::DB >  db,
std::string *  old_key = nullptr 
)

Put metadata into database with relative_path as the key.

Parameters
relative_pathDatabase key
dbPointer to RocksDB database
old_keystring pointer to old key to remove if not nullptr

Member Data Documentation

◆ access_count_

uintmax_t Metadata::access_count_ = 0
private

Number of times the file was accessed since last tiering. Resets to 0 after each popularity calculation.

◆ not_found_

bool Metadata::not_found_ = false
private

Set to true when the file metadata could not be retrieved from the database.

◆ pinned_

bool Metadata::pinned_ = false
private

Flag to determine whether to ignore file while tiering. When true, the file stays in the tier it is in.

◆ popularity_

double Metadata::popularity_ = MULTIPLIER * AVG_USAGE
private

Moving average of file usage frequency in accesses per hour. Used to sort list of files to determine which tiers they belong in.

◆ tier_path_

std::string Metadata::tier_path_
private

The backend path of the tier. This + relative path is the real location of the file.


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