wrench::LogicalFileSystem

class LogicalFileSystem

A class that implements a weak file system abstraction.

Subclassed by wrench::LogicalFileSystemLRUCaching, wrench::LogicalFileSystemNoCaching

Public Functions

void createDirectory(const std::string &absolute_path)

Create a new directory.

Parameters:

absolute_path – the directory’s absolute path

Throws:

std::invalid_argument

virtual void decrementNumRunningTransactionsForFileInDirectory(const std::shared_ptr<DataFile> &file, const std::string &absolute_path) = 0

Decrement the number of running transactions that have to do with a file.

Parameters:
  • file – the file

  • absolute_path – the file path

bool doesDirectoryExist(const std::string &absolute_path)

Checks whether a directory exists.

Parameters:

absolute_path – the directory’s absolute path

Returns:

true if the directory exists

simgrid::s4u::Disk *getDisk()

Get the disk on which this file system runs.

Returns:

The SimGrid disk on which this file system is mounted

double getFileLastWriteDate(const std::shared_ptr<DataFile> &file, const std::string &absolute_path)

Retrieve the file’s last write date.

Parameters:
  • file – the file

  • absolute_path – the file path

Returns:

a date in seconds (returns -1.0) if file in not found

double getFreeSpace() const

Get the file system’s free space.

Returns:

the free space in bytes

double getTotalCapacity() const

Get the total capacity.

Returns:

the total capacity

double getTotalNumFiles() const
Returns:

Total number of files currently stored in Filesytem

virtual void incrementNumRunningTransactionsForFileInDirectory(const std::shared_ptr<DataFile> &file, const std::string &absolute_path) = 0

Increment the number of running transactions that have to do with a file.

Parameters:
  • file – the file

  • absolute_path – the file path

bool isDirectoryEmpty(const std::string &absolute_path)

Checks whether a directory is empty.

Parameters:

absolute_path – the directory’s absolute path

Throws:

std::invalid_argument

Returns:

true if the directory is empty

bool isFileInDirectory(const std::shared_ptr<DataFile> &file, const std::string &absolute_path)

Checks whether a file is in a directory.

Parameters:
  • file – the file

  • absolute_path – the directory’s absolute path

Throws:

std::invalid_argument

Returns:

true if the file is present, false if not (or if directory does not exist)

std::set<std::shared_ptr<DataFile>> listFilesInDirectory(const std::string &absolute_path)

Get the files in a directory as a set.

Parameters:

absolute_path – the directory’s absolute path

Throws:

std::invalid_argument

Returns:

a set of files

virtual void removeAllFilesInDirectory(const std::string &absolute_path) = 0

Remove all files in a directory.

Parameters:

absolute_path – the directory’s absolute path

Throws:

std::invalid_argument

void removeEmptyDirectory(const std::string &absolute_path)

Remove an empty directory.

Parameters:

absolute_path – the directory’s absolute path

Throws:

std::invalid_argument

virtual void removeFileFromDirectory(const std::shared_ptr<DataFile> &file, const std::string &absolute_path) = 0

Remove a file in a directory.

Parameters:
  • file – the file to remove

  • absolute_path – the directory’s absolute path

Throws:

std::invalid_argument

bool reserveSpace(const std::shared_ptr<DataFile> &file, const std::string &absolute_path)

Reserve space for a file that will be stored.

Parameters:
  • file – the file

  • absolute_path – the path where it will be written

Returns:

true on success, false on failure

void stageFile(const std::shared_ptr<DataFile> &file, std::string absolute_path)

Stage file in directory.

Parameters:
  • file – the file to stage

  • absolute_path – the directory’s absolute path (at the mount point)

Throws:

std::invalid_argument

virtual void storeFileInDirectory(const std::shared_ptr<DataFile> &file, const std::string &absolute_path) = 0

Store file in directory.

Parameters:
  • file – the file to store

  • absolute_path – the directory’s absolute path (at the mount point)

Throws:

std::invalid_argument

void unreserveSpace(const std::shared_ptr<DataFile> &file, const std::string &absolute_path)

Unreserved space that was saved for a file (likely a failed transfer)

Parameters:
  • file – the file

  • absolute_path – the path where it would have been written

Throws:

std::invalid_argument

virtual void updateReadDate(const std::shared_ptr<DataFile> &file, const std::string &absolute_path) = 0

Update a file’s read date.

Parameters:
  • file – the file

  • absolute_path – the path

Public Static Functions

static std::unique_ptr<LogicalFileSystem> createLogicalFileSystem(const std::string &hostname, StorageService *storage_service, const std::string &mount_point = DEV_NULL, const std::string &eviction_policy = "NONE")

Method to create a LogicalFileSystem instance.

Parameters:
  • hostname – hostname on which the disk is mounted

  • storage_service – storage service for which this file system is created

  • mount_point – the mountpoint

  • eviction_policy – the cache eviction policy (“NONE”, “LRU”)

Returns:

a shared pointer to a LogicalFileSystem instance

Public Static Attributes

static const std::string DEV_NULL = "/dev/null"

A constant that signifies /dev/null, when the actual location/path/mountpoint/etc. is unknown.

class FileOnDisk

A helper class to describe a file instance on the file system.

Subclassed by wrench::LogicalFileSystemLRUCaching::FileOnDiskLRUCaching

Public Functions

inline explicit FileOnDisk(double last_write_date)

Constructor.

Parameters:

last_write_date – the file’s last write date

Public Members

double last_write_date

the file’s last write date