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

File object to represent a file in the autotier filesystem. More...

#include <file.hpp>

Collaboration diagram for File:
Collaboration graph
[legend]

Public Member Functions

 File (void)
 Construct a new empty File object. More...
 
 File (fs::path full_path, std::shared_ptr< rocksdb::DB > db, Tier *tptr)
 Construct a new File object. More...
 
 File (const File &other)
 Copy construct a new File object. More...
 
 ~File ()
 Destroy the File object Calls metadata.update(relative_path_.c_str(), db_) to store newly updated metadata in database after tiering. More...
 
void update_db (void)
 Call Metadata::update() More...
 
void calc_popularity (double period_seconds)
 Calculate new popularity value of file. y[n] = MULTIPLIER * x / DAMPING + (1.0 - 1.0 / DAMPING) * y[n-1] where x is file usage frequency. More...
 
fs::path full_path (void) const
 Return full backend path to file via tier. More...
 
fs::path relative_path (void) const
 Return path to file relative to the tier path and the filesystem mountpoint. More...
 
Tiertier_ptr (void) const
 Get the pointer to the tier currently holding this file. More...
 
double popularity (void) const
 Get popularity in accesses per hour. More...
 
struct timeval atime (void) const
 Get last access time of file. More...
 
ffd::Bytes size (void) const
 Get size of file on disk in bytes. More...
 
void pin (void)
 Set metadata_.pinned_. Keeps file in current tier.
 
bool is_pinned (void) const
 Get metadata_.pinned_. Check if file is pinned. More...
 
void transfer_to_tier (Tier *tptr)
 Update tier_ptr_ and metadata_.tier_path_ then call metadata_.update(). More...
 
void overwrite_times (void) const
 Call utimes() on file path with the saved atime and mtime so they stay the same as before tiering. More...
 
void change_path (const fs::path &new_path)
 Update database with new path. More...
 

Private Attributes

ffd::Bytes size_
 Size of file on disk.
 
Tiertier_ptr_
 Pointer to Tier object representing the tier containing this file.
 
struct timeval times_ [2]
 atime and mtime of the file. Used to overwrite changes from copying file.
 
time_t atime_
 Just the atime of the file.
 
time_t ctime_
 Just the ctime of the file.
 
fs::path relative_path_
 Location of file relative to the tier and the filesystem mountpoint.
 
std::shared_ptr< rocksdb::DB > db_
 Database storing metadata.
 
Metadata metadata_
 Metadata of object retrieved from database.
 

Detailed Description

File object to represent a file in the autotier filesystem.

Constructor & Destructor Documentation

◆ File() [1/3]

File::File ( void  )

Construct a new empty File object.

◆ File() [2/3]

File::File ( fs::path  full_path,
std::shared_ptr< rocksdb::DB >  db,
Tier tptr 
)

Construct a new File object.

Parameters
full_pathFull backend path to file
dbRocksdb database pointer
tptrPointer to tier in which file was found

◆ File() [3/3]

File::File ( const File other)

Copy construct a new File object.

Parameters
other

◆ ~File()

File::~File ( )

Destroy the File object Calls metadata.update(relative_path_.c_str(), db_) to store newly updated metadata in database after tiering.

Member Function Documentation

◆ atime()

struct timeval File::atime ( void  ) const

Get last access time of file.

Returns
struct timeval

◆ calc_popularity()

void File::calc_popularity ( double  period_seconds)

Calculate new popularity value of file. y[n] = MULTIPLIER * x / DAMPING + (1.0 - 1.0 / DAMPING) * y[n-1] where x is file usage frequency.

Parameters
period_secondsPeriod over which to calculate

◆ change_path()

void File::change_path ( const fs::path &  new_path)

Update database with new path.

Parameters
new_path

◆ full_path()

fs::path File::full_path ( void  ) const

Return full backend path to file via tier.

Returns
fs::path Full backend path

◆ is_pinned()

bool File::is_pinned ( void  ) const

Get metadata_.pinned_. Check if file is pinned.

Returns
true File is pinned
false File is not pinned

◆ overwrite_times()

void File::overwrite_times ( void  ) const

Call utimes() on file path with the saved atime and mtime so they stay the same as before tiering.

◆ popularity()

double File::popularity ( void  ) const

Get popularity in accesses per hour.

Returns
double EMA of accesses per hour.

◆ relative_path()

fs::path File::relative_path ( void  ) const

Return path to file relative to the tier path and the filesystem mountpoint.

Returns
fs::path Relative path

◆ size()

ffd::Bytes File::size ( void  ) const

Get size of file on disk in bytes.

Returns
ffd::Bytes Size of file

◆ tier_ptr()

Tier * File::tier_ptr ( void  ) const

Get the pointer to the tier currently holding this file.

Returns
Tier* Tier holding this file

◆ transfer_to_tier()

void File::transfer_to_tier ( Tier tptr)

Update tier_ptr_ and metadata_.tier_path_ then call metadata_.update().

Subtracts file size from old tier, updates tptr_ to new tier, adds file size to new tier, updates metadata.tier_path, then calls metadata.update() to update the db.

Parameters
tptrNew tier.

◆ update_db()

void File::update_db ( void  )

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