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

Class to represent each tier in the filesystem. More...

#include <tier.hpp>

Collaboration diagram for Tier:
Collaboration graph
[legend]

Public Member Functions

 Tier (std::string id, const fs::path &path, const ffd::Quota &quota)
 Construct a new Tier object. More...
 
 Tier (Tier &&other)
 Copy construct a new Tier object. More...
 
 ~Tier ()=default
 Destroy the Tier object. More...
 
void add_file_size (ffd::Bytes size)
 Add size bytes to usage_. More...
 
void subtract_file_size (ffd::Bytes size)
 Subtract size bytes from usage. More...
 
void size_delta (ffd::Bytes old_size, ffd::Bytes new_size)
 Subtract old_size then add new_size, locking mutex for thread safety. More...
 
void add_file_size_sim (ffd::Bytes size)
 Add size bytes to sim_usage_. More...
 
void subtract_file_size_sim (ffd::Bytes size)
 Subtract size bytes from sim_usage. More...
 
void quota_percent (double quota_percent)
 Set quota percentage. More...
 
double quota_percent (void) const
 Get quota percentage. More...
 
ffd::Quota quota (void) const
 Get quota_. More...
 
bool full_test (const ffd::Bytes &file_size) const
 returns true if file would make tier overfilled. (usage_ + file.size() > quota_bytes_). More...
 
const fs::path & path (void) const
 Get path to root of tier. More...
 
const std::string & id (void) const
 Get user-defined ID of tier. More...
 
void enqueue_file_ptr (File *fptr)
 Push file pointer into incoming_files_. More...
 
void transfer_files (int buff_sz, const fs::path &run_path)
 Iterate through incoming_files_ and move each file into the tier. More...
 
bool move_file (const fs::path &old_path, const fs::path &new_path, int buff_sz, bool *conflicted=nullptr, std::string orig_tier="") const
 Called in transfer_files() to actually copy the file and remove the old one. More...
 
void usage (ffd::Bytes usage)
 Set tier usage_ in bytes. More...
 
double usage_percent (void) const
 Return real current usage as percent. More...
 
ffd::Bytes usage_bytes (void) const
 Return real current usage in bytes. More...
 
void reset_sim (void)
 Set sim_usage_ to zero. More...
 
ffd::Bytes capacity (void) const
 Return capacity in bytes. More...
 

Private Member Functions

void copy_ownership_and_perms (const fs::path &old_path, const fs::path &new_path) const
 Copy ownership and permissions from old_path to new_path, called after copying a file to a different tier. More...
 

Private Attributes

ffd::Quota quota_
 Holds maximum size and percent allotted.
 
ffd::Bytes usage_
 Real current bytes used in underlying filesystem.
 
ffd::Bytes sim_usage_
 Number of bytes used, used while simulating the tiering of files to determine where to place each file.
 
std::string id_
 User-defined friendly name of tier, in square bracket header of tier definition in config file.
 
fs::path path_
 Backend path to tier.
 
std::vector< File * > incoming_files_
 Queue of files to be placed into the tier, filled during the simulation of tiering and used while actually tiering.
 
std::mutex usage_mt_
 Mutex to be used in {add,subtract}_file_size() for FUSE threads.
 

Detailed Description

Class to represent each tier in the filesystem.

Constructor & Destructor Documentation

◆ Tier() [1/2]

Tier::Tier ( std::string  id,
const fs::path &  path,
const ffd::Quota quota 
)

Construct a new Tier object.

Parameters
idUser-defined ID of tier from config subsection header
pathPath to tier in filesystem

◆ Tier() [2/2]

Tier::Tier ( Tier &&  other)
inline

Copy construct a new Tier object.

Parameters
otherTier to be copied

◆ ~Tier()

Tier::~Tier ( )
default

Destroy the Tier object.

Member Function Documentation

◆ add_file_size()

void Tier::add_file_size ( ffd::Bytes  size)

Add size bytes to usage_.

Parameters
size

◆ add_file_size_sim()

void Tier::add_file_size_sim ( ffd::Bytes  size)

Add size bytes to sim_usage_.

Parameters
size

◆ capacity()

ffd::Bytes Tier::capacity ( void  ) const

Return capacity in bytes.

Returns
ffd::Bytes

◆ copy_ownership_and_perms()

void Tier::copy_ownership_and_perms ( const fs::path &  old_path,
const fs::path &  new_path 
) const
private

Copy ownership and permissions from old_path to new_path, called after copying a file to a different tier.

Parameters
old_pathPath to file before moving
new_pathPath to file after moving

◆ enqueue_file_ptr()

void Tier::enqueue_file_ptr ( File fptr)

Push file pointer into incoming_files_.

Parameters
fptr

◆ full_test()

bool Tier::full_test ( const ffd::Bytes file_size) const

returns true if file would make tier overfilled. (usage_ + file.size() > quota_bytes_).

Parameters
fileFile to test
Returns
true file would make tier overfilled
false file would fit in tier

◆ id()

const std::string & Tier::id ( void  ) const

Get user-defined ID of tier.

Returns
const fs::path&

◆ move_file()

bool Tier::move_file ( const fs::path &  old_path,
const fs::path &  new_path,
int  buff_sz,
bool *  conflicted = nullptr,
std::string  orig_tier = "" 
) const

Called in transfer_files() to actually copy the file and remove the old one.

Parameters
old_path
new_path
buff_sz
conflicted
orig_tier
Returns
true
false

◆ path()

const fs::path & Tier::path ( void  ) const

Get path to root of tier.

Returns
const std::string&

◆ quota()

ffd::Quota Tier::quota ( void  ) const

Get quota_.

Returns
ffd::Quota

◆ quota_percent() [1/2]

void Tier::quota_percent ( double  quota_percent)

Set quota percentage.

Parameters
quota_percent

◆ quota_percent() [2/2]

double Tier::quota_percent ( void  ) const

Get quota percentage.

Returns
double

◆ reset_sim()

void Tier::reset_sim ( void  )

Set sim_usage_ to zero.

◆ size_delta()

void Tier::size_delta ( ffd::Bytes  old_size,
ffd::Bytes  new_size 
)

Subtract old_size then add new_size, locking mutex for thread safety.

Parameters
old_sizeSubtract this
new_sizeAdd this

◆ subtract_file_size()

void Tier::subtract_file_size ( ffd::Bytes  size)

Subtract size bytes from usage.

Parameters
size

◆ subtract_file_size_sim()

void Tier::subtract_file_size_sim ( ffd::Bytes  size)

Subtract size bytes from sim_usage.

Parameters
size

◆ transfer_files()

void Tier::transfer_files ( int  buff_sz,
const fs::path &  run_path 
)

Iterate through incoming_files_ and move each file into the tier.

Parameters
buff_sz
run_path

◆ usage()

void Tier::usage ( ffd::Bytes  usage)

Set tier usage_ in bytes.

Parameters
usage

◆ usage_bytes()

ffd::Bytes Tier::usage_bytes ( void  ) const

Return real current usage in bytes.

Returns
ffd::Bytes

◆ usage_percent()

double Tier::usage_percent ( void  ) const

Return real current usage as percent.

Returns
double

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