wrench::StorageService

class StorageService : public wrench::Service

The storage service base class.

Subclassed by wrench::SimpleStorageService, wrench::XRootD::Node

Public Functions

StorageService(const std::string &hostname, const std::set<std::string> &mount_points, const std::string &service_name)

Constructor.

Parameters
  • hostname – the name of the host on which the service should run

  • mount_points – the mount points of each disk usable by the service. “/dev/null” is a reserved mount point with no physical disk associated. It acts similar to /dev/null on unix systems.

  • service_name – the name of the storage service

Throws

std::invalid_argument

virtual void createFile(const std::shared_ptr<DataFile> &file)

Store a file at a particular mount point ex-nihilo. Doesn’t notify a file registry service and will do nothing (and won’t complain) if the file already exists at that location.

Parameters

file – a file

virtual void createFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &location)

Store a file at a particular mount point ex-nihilo. Doesn’t notify a file registry service and will do nothing (and won’t complain) if the file already exists at that location.

Parameters
  • file – a file

  • location – a file location, must be the same object as the function is envoked on

Throws

std::invalid_argument

virtual void createFile(const std::shared_ptr<DataFile> &file, const std::string &path)

Store a file at a particular mount point ex-nihilo. Doesn’t notify a file registry service and will do nothing (and won’t complain) if the file already exists at that location.

Parameters
  • file – a file

  • path – path to file

virtual void deleteFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileRegistryService> &file_registry_service = nullptr)

Synchronously delete a file at a location.

Parameters
  • file – the file

  • file_registry_service – a file registry service that should be updated once the file deletion has (successfully) completed (none if nullptr)

Throws
std::map<std::string, double> getFreeSpace()

Synchronously asks the storage service for its capacity at all its mount points.

Throws
Returns

The free space in bytes of each mount point, as a map

virtual double getLoad() = 0

Get the theoretical load of a service.

Returns

the load on the service

virtual std::string getMountPoint()

Get the mount point (will throw is more than one)

Returns

the (sole) mount point of the service

virtual std::set<std::string> getMountPoints()

Get the set of mount points.

Returns

the set of mount points

std::map<std::string, double> getTotalSpace()

Get the total static capacity of the storage service (in zero simulation time)

Returns

capacity of the storage service (double) for each mount point, in a map

virtual bool hasMountPoint(const std::string &mp)

Checked whether the storage service has a particular mount point.

Parameters

mp – a mount point

Returns

true whether the service has that mount point

virtual bool hasMultipleMountPoints()

Checked whether the storage service has multiple mount points.

Returns

true whether the service has multiple mount points

bool isScratch() const

Determines whether the storage service is a scratch service of a ComputeService.

Returns

true if it is, false otherwise

virtual bool lookupFile(const std::shared_ptr<DataFile> &file)

Synchronously asks the storage service whether it holds a file.

Parameters

file – the file

Throws
Returns

true or false

virtual void readFile(const std::shared_ptr<DataFile> &file)

Synchronously read a file from the storage service.

Parameters

file – the file

Throws
virtual void readFile(const std::shared_ptr<DataFile> &file, const std::string &path)

Synchronously read a file from the storage service.

Parameters
  • file – the file

  • path – the absolute file path

Throws
virtual void readFile(const std::shared_ptr<DataFile> &file, const std::string &path, double num_bytes)

Synchronously read a file from the storage service.

Parameters
  • file – the file

  • path – the absolute file path

  • num_bytes – the number of bytes to read

Throws
virtual void readFile(const std::shared_ptr<DataFile> &file, double num_bytes)

Synchronously read a file from the storage service.

Parameters
  • file – the file

  • num_bytes – the number of bytes to read

Throws
void setScratch()

Indicate that this storace service is a scratch service of a ComputeService.

virtual void stop() override

Stop the service.

virtual void writeFile(const std::shared_ptr<DataFile> &file)

Synchronously write a file to the storage service.

Parameters

file – the file

Throws

ExecutionException

virtual void writeFile(const std::shared_ptr<DataFile> &file, const std::string &path)

Synchronously write a file to the storage service.

Parameters
  • file – the file

  • path – path to file

Throws

ExecutionException

Public Static Functions

static void copyFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &src_location, const std::shared_ptr<FileLocation> &dst_location)

Synchronously ask the storage service to read a file from another storage service.

Parameters
  • file – the file to copy

  • src_location – the location where to read the file

  • dst_location – the location where to write the file

Throws
static void deleteFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &location, const std::shared_ptr<FileRegistryService> &file_registry_service = nullptr)

Synchronously delete a file at a location.

Parameters
  • file – the file

  • location – the file’s location

  • file_registry_service – a file registry service that should be updated once the file deletion has (successfully) completed (none if nullptr)

Throws
static void initiateFileCopy(simgrid::s4u::Mailbox *answer_mailbox, const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &src_location, const std::shared_ptr<FileLocation> &dst_location)

Asynchronously ask for a file copy between two storage services.

Parameters
  • answer_mailbox – the mailbox to which a notification message will be sent

  • file – the file

  • src_location – the source location

  • dst_location – the destination location

Throws
static bool lookupFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &location)

Synchronously asks the storage service whether it holds a file.

Parameters
  • file – the file

  • location – the file location

Throws
Returns

true or false

static void readFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &location)

Synchronously read a file from the storage service.

Parameters
  • file – the file

  • location – the location to read the file from

Throws
static void readFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &location, double num_bytes)

Synchronously read a file from the storage service.

Parameters
  • file – the file

  • location – the location to read the file from

  • num_bytes_to_read – number of bytes to read from the file

Throws
static void readFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &location, simgrid::s4u::Mailbox *answer_mailbox, simgrid::s4u::Mailbox *chunk_receiving_mailbox, double num_bytes)

Synchronously read a file from the storage service.

Parameters
  • file – the file

  • location – the file location

  • answer_mailbox – the answer mailbox

  • chunk_receiving_mailbox – the chunk receiving mailbox (WILL BE RETIRED BY THIS FUNCTION)

  • num_bytes_to_read – number of bytes to read

static void readFiles(std::map<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation>> locations)

Synchronously and sequentially read a set of files from storage services.

Parameters

locations – a map of files to locations

Throws
static void writeFile(const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &location)

Synchronously write a file to the storage service.

Parameters
  • file – the file

  • location – the location to write it to

Throws

ExecutionException

static void writeFiles(std::map<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation>> locations)

Synchronously and sequentially upload a set of files from storage services.

Parameters

locations – a map of files to locations

Throws