wrench::SimpleStorageService

class SimpleStorageService : public wrench::StorageService

A storage service that provides direct access to some storage resources (e.g., one or more disks). An important (configurable) property of the storage service is SimpleStorageServiceProperty::BUFFER_SIZE (see documentation thereof), which defines the buffer size that the storage service uses. Specifically, when the storage service receives/sends data from/to the network, it does so in a loop over data “chunks”, with pipelined network and disk I/O operations. The smaller the buffer size the more “fluid” the model, but the more time-consuming the simulation. A large buffer size, however, may lead to less realistic simulations. At the extreme, an infinite buffer size would correspond to fully sequential executions (first a network receive/send, and then a disk write/read). Setting the buffer size to “0” corresponds to a fully fluid model in which individual data chunk operations are not simulated, thus achieving both accuracy (unless one specifically wishes to study the effects of buffering) and quick simulation times. For now, setting the buffer size to “0” is not implemented. The default buffer size is 10 MiB (note that the user can always declare a disk with arbitrary bandwidth in the platform description XML).

Subclassed by wrench::SimpleStorageServiceBufferized, wrench::SimpleStorageServiceNonBufferized

Public Functions

~SimpleStorageService() override

Destructor.

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

Create a file at the storage service (in zero simulated time)

Parameters:

file – a file

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

Create a file at the storage service (in zero simulated time)

Parameters:
  • file – a file

  • path – a path

virtual void createFile(const std::shared_ptr<FileLocation> &location) override

Create a file at the storage service (in zero simulated time)

Parameters:

location – a location

void createFile(const std::shared_ptr<FileLocation> &location) = 0

Create a file at the storage service (in zero simulated time)

Parameters:

location – a location

inline void deleteFile(const std::shared_ptr<DataFile> &file)

Delete a file at the storage service (incurs simulated overheads)

Parameters:

file – a file

inline void deleteFile(const std::shared_ptr<DataFile> &file, const std::string &path)

Delete a file at the storage service (incurs simulated overheads)

Parameters:
  • file – a file

  • path – a path

inline void deleteFile(const std::shared_ptr<FileLocation> &location)

Delete a file at the storage service (incurs simulated overheads)

Parameters:

location – a location

virtual std::string getBaseRootPath() override

Get the base root path. Note that if this service has multiple mount points, this method will throw an exception.

Returns:

simgrid::s4u::Disk *getDiskForPathOrNull(const std::string &path)

Gets the disk that stores a path.

Parameters:

path – a path

Returns:

a disk, or nullptr if path is invalid

virtual double getFileLastWriteDate(const std::shared_ptr<DataFile> &file, const std::string &path = "/") override

Get a file’s last write date at a location (in zero simulated time)

Parameters:
  • file – the file

  • path – the path

Returns:

the file’s last write date, or -1 if the file is not found or if the path is invalid

virtual double getFileLastWriteDate(const std::shared_ptr<FileLocation> &location) override

Get a file’s last write date at a the storage service (in zero simulated time)

Parameters:

location – a location

Returns:

a date in seconds, or -1 if the file is not found

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

Get the set of mount points.

Returns:

the set of mount points

inline std::string getPathMountPoint(const std::string &path)

Get the mount point that stores a path.

Parameters:

path – path

Returns:

a mount point

virtual double getTotalFilesZeroTime() override

Get the number of files registered to the filesystem(s) associated with this service (no simulated overhead)

Service number of allocated files tracing (doesn’t incur simulated overhead)

Returns:

Current number of registered Datafile for all filesystem(s) from this service

virtual double getTotalFreeSpaceZeroTime() override

Return current total free space from all mount point (in zero simulation time) for IO tracing purpose.

Returns:

total free space in bytes

virtual double getTotalSpace() override

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

Returns:

capacity of the storage service in bytes

inline bool hasFile(const std::shared_ptr<DataFile> &file)

Determines whether a file is present at the storage service (in zero simulated time)

Parameters:

file – a file

Returns:

true if the file is present, false otherwise

inline bool hasFile(const std::shared_ptr<DataFile> &file, const std::string &path)

Determines whether a file is present at the storage service (in zero simulated time)

Parameters:
  • file – a file

  • path – a path

Returns:

true if the file is present, false otherwise

virtual bool hasFile(const std::shared_ptr<FileLocation> &location) override

Determines whether the storage service has the file. This doesn’t simulate anything and is merely a zero-simulated-time data structure lookup. If you want to simulate the overhead of querying the StorageService, instead use lookupFile().

Parameters:

location – a location

Returns:

true if the file is present, false otherwise

bool hasFile(const std::shared_ptr<FileLocation> &location) = 0

Determines whether a file is present at the storage service (in zero simulated time)

Parameters:

location – a location

Returns:

true if the file is present, false otherwise

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

bool hasMultipleMountPoints()

Determine whether the storage service has multiple mount points.

Returns:

true if multiple mount points, false otherwise

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

Lookup whether a file exists on the storage service (incurs simulated overheads)

Parameters:

file – a file

Returns:

true if the file is present, or false

inline bool lookupFile(const std::shared_ptr<DataFile> &file, const std::string &path)

Lookup whether a file exists on the storage service (incurs simulated overheads)

Parameters:
  • file – a file

  • path – a path

Returns:

true if the file is present, or false

inline bool lookupFile(const std::shared_ptr<FileLocation> &location)

Lookup whether a file exists at a location on the storage service (incurs simulated overheads)

Parameters:

location – a location

Returns:

true if the file is present, or false

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

Read a file at the storage service (incurs simulated overheads)

Parameters:

file – a file

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

Read a file at the storage service (incurs simulated overheads)

Parameters:
  • file – a file

  • path – a path

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

Read a file at the storage service (incurs simulated overheads)

Parameters:
  • file – a file

  • path – a path

  • num_bytes – a number of bytes to read

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

Read a file at the storage service (incurs simulated overheads)

Parameters:
  • file – a file

  • num_bytes – a number of bytes to read

inline void readFile(const std::shared_ptr<FileLocation> &location)

Read a file at the storage service (incurs simulated overheads)

Parameters:

location – a location

inline void readFile(const std::shared_ptr<FileLocation> &location, double num_bytes)

Read a file at the storage service (incurs simulated overheads)

Parameters:
  • location – a location

  • num_bytes – a number of bytes to read

virtual void removeDirectory(const std::string &path) override

Remove a directory and all files at the storage service (in zero simulated time)

Parameters:

path – a path

virtual void removeFile(const std::shared_ptr<FileLocation> &location) override

Remove a file at the storage service (in zero simulated time)

Parameters:

location – a location

inline virtual bool reserveSpace(std::shared_ptr<FileLocation> &location) override

Reserve space at the storage service.

Parameters:

location – a location

Returns:

true if success, false otherwise

inline virtual void unreserveSpace(std::shared_ptr<FileLocation> &location) override

Unreserve space at the storage service.

Parameters:

location – a location

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

Write a file at the storage service (incurs simulated overheads)

Parameters:

file – a file

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

Write a file at the storage service (incurs simulated overheads)

Parameters:
  • file – a file

  • path – a path

inline void writeFile(const std::shared_ptr<FileLocation> &location)

Write a file at the storage service (incurs simulated overheads)

Parameters:

location – a location

Public Static Functions

static SimpleStorageService *createSimpleStorageService(const std::string &hostname, std::set<std::string> mount_points, WRENCH_PROPERTY_COLLECTION_TYPE property_list = {}, WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list = {})

Factory method to create SimpleStorageService instances.

Parameters:
  • hostname – the name of the host on which to start the service

  • mount_points – the set of mount points

  • property_list – a property list ({} means “use all defaults”)

  • messagepayload_list – a message payload list ({} means “use all defaults”)

Returns:

a pointer to a simple storage service