wrench::StorageServiceProxy

class StorageServiceProxy : public wrench::StorageService

Implementation of a storage service proxy.

Public Functions

explicit StorageServiceProxy(const std::string &hostname, const std::shared_ptr<StorageService> &cache = nullptr, const std::shared_ptr<StorageService> &default_remote = nullptr, WRENCH_PROPERTY_COLLECTION_TYPE properties = {}, WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE message_payloads = {})

Constructor.

Parameters:
  • hostname – The host to run on

  • cache – A Storage server to use as a cache. Ideal on the same host

  • default_remote – A remote file server to use as a default target. Defaults to nullptr

  • properties – The wrench property overrides

  • message_payloads – The wrench message payload overrides

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

StorageServiceProxy.createFile() is ambiguous where the file should go. You should call createFile on the remote service where you wish to create the file. If you want it to start cached, you should also call StorageServiceProxy.getCache().createFile.

Parameters:

location – the file 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 void deleteFile(const std::shared_ptr<StorageService> &targetServer, const std::shared_ptr<DataFile> &file)

Delete a file.

Parameters:
  • targetServer – the target server

  • file – the file

void deleteFile(S4U_CommPort *answer_commport, const std::shared_ptr<FileLocation> &location, bool wait_for_answer)

Delete a file on the storage service.

Parameters:
  • answer_commport – the answer commport to which the reply from the server should be sent

  • location – the location to delete

  • wait_for_answer – whether this call should

virtual double getBufferSize() const override

Get the buffer size of the cache (which could be 0 or >0), or 0 if there is no cache.

Returns:

a size in bytes

std::shared_ptr<StorageService> getCache()

Get the proxy’s associated cache.

Returns:

the cache storage service

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

Get the last write date of a file.

Forward to remote server.

Parameters:

location – the file location

Returns:

a (simulated) date in seconds

virtual double getLoad() override

Get the load of the cache

Returns:

the load of the cache

virtual double getTotalFreeSpaceAtPath(const std::string &path) override

Synchronously asks the proxy service for its capacity (which returns the remote)

Parameters:

path – the path

Returns:

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

virtual double getTotalSpace() override

Synchronously asks the proxy service for its total capacity (which returns the remote)

Returns:

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

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 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 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

virtual bool isBufferized() const override

Returns true if the cache is bufferized, false otherwise.

Returns:

true or false

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

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

Lookup a file.

Parameters:
  • targetServer – the target server

  • file – the file

Returns:

true if the file is present, false otherwise

bool lookupFile(S4U_CommPort *answer_commport, const std::shared_ptr<FileLocation> &location)

Asks the storage service whether it holds a file.

Parameters:
  • answer_commport – the answer commport to which the reply from the server should be sent

  • location – the location to lookup

Returns:

true if the file is present, false otherwise

virtual int main() override

Main method of the daemon.

Returns:

0 on termination

bool processNextMessage()

Process a received control message.

Returns:

false if the daemon should terminate

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 readFile(const std::shared_ptr<StorageService> &targetServer, const std::shared_ptr<DataFile> &file)

Read a file.

Parameters:
  • targetServer – the target server

  • file – the file

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

Read a file.

Parameters:
  • targetServer – the target server

  • file – the file

  • path – the file path

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

Read a file.

Parameters:
  • targetServer – the target server

  • file – the file

  • path – the file path

  • num_bytes – the number of bytes to read

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

Read a file.

Parameters:
  • targetServer – the target server

  • file – the file

  • num_bytes – the number of bytes to read

void readFile(S4U_CommPort *answer_commport, const std::shared_ptr<FileLocation> &location, double num_bytes, bool wait_for_answer)

Read a file from the storage service.

Parameters:
  • answer_commport – the commport on which to expect the answer

  • location – the location

  • num_bytes – the number of bytes to read

  • wait_for_answer – whether to wait for the answer

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

Detect if a remote file read is already in process for this file. If it is, return true.

Parameters:

file – the file to find

Returns:

True if the message was processed. False otherwise

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

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

Parameters:

path – a path

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

StorageServiceProxy.removeFile() is ambiguous where the file should go. You should call removeFile on the remote service where you wish to remove the file. If you want it to start cached, you should also call StorageServiceProxy.getCache().removeFile.

Parameters:

location – the file 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

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

Write a file.

Parameters:
  • targetServer – the target server

  • file – the file

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

Write a file.

Parameters:
  • targetServer – the target server

  • file – the file

  • path – the file path

void writeFile(S4U_CommPort *answer_commport, const std::shared_ptr<FileLocation> &location, double num_bytes_to_write, bool wait_for_answer)

Synchronously write a file to the storage service.

Parameters:
  • answer_commport – the commport on which to expect the answer

  • location – the location

  • num_bytes_to_write – the number of bytes to write to the file

  • wait_for_answer – whether to wait for the answer

Throws:

ExecutionException

Public Static Functions

static inline std::shared_ptr<StorageServiceProxy> createCachelessProxy(const std::string &hostname, const std::shared_ptr<StorageService> &default_remote, WRENCH_PROPERTY_COLLECTION_TYPE properties = {}, WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE message_payloads = {})

Factory to create a StorageServiceProxy that does not cache reads, and only forwards requests to another service.

Parameters:
  • hostname – hostname

  • default_remote – The StorageService to use as a remote file source

  • properties – Properties for the fileServiceProxy

  • message_payloads – Message Payloads for the fileServiceProxy

Returns:

the StorageServiceProxy created

static inline std::shared_ptr<StorageServiceProxy> createCachelessRedirectProxy(const std::string &hostname, WRENCH_PROPERTY_COLLECTION_TYPE properties = {}, WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE message_payloads = {})

Factory to create a StorageServiceProxy that does not cache reads, and does not have a default destination to forward too.

Parameters:
  • hostname – hostname

  • properties – Properties for the fileServiceProxy

  • message_payloads – Message Payloads for the fileServiceProxy

Returns:

the StorageServiceProxy created

static inline std::shared_ptr<StorageServiceProxy> createRedirectProxy(const std::string &hostname, const std::shared_ptr<StorageService> &cache, const std::shared_ptr<StorageService> &remote = nullptr, WRENCH_PROPERTY_COLLECTION_TYPE properties = {}, WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE message_payloads = {})

Factory to create a StorageServiceProxy that can a default destination to forward requests too, and will cache requests as they are made.

Parameters:
  • hostname – hostname

  • cache – The StorageService to use as a Cache

  • remote – The StorageService to use as a remote file source

  • properties – Properties for the fileServiceProxy

  • message_payloads – Message Payloads for the fileServiceProxy

Returns:

the StorageServiceProxy created