The storage service base class. More...

#include <StorageService.h>

Inheritance diagram for wrench::StorageService:
wrench::Service wrench::S4U_Daemon wrench::SimpleStorageService

Public Member Functions

 StorageService (const std::string &hostname, const std::string &service_name, const std::string &data_mailbox_name_prefix, double capacity)
 Constructor. More...
 
virtual void copyFile (WorkflowFile *file, StorageService *src, std::string src_dir, std::string dst_dir)
 Synchronously ask the storage service to read a file from another storage service. More...
 
virtual void copyFile (WorkflowFile *file, StorageService *src)
 Synchronously ask the storage service to read a file from another storage service. More...
 
virtual void copyFile (WorkflowFile *file, StorageService *src, WorkflowJob *src_job, WorkflowJob *dst_job)
 Synchronously ask the storage service to read a file from another storage service. More...
 
virtual void deleteFile (WorkflowFile *file, FileRegistryService *file_registry_service=nullptr)
 Synchronously asks the storage service to delete a file copy. More...
 
virtual void deleteFile (WorkflowFile *file, std::string dst_dir, FileRegistryService *file_registry_service=nullptr)
 Synchronously ask the storage service to delete a file copy. More...
 
virtual void deleteFile (WorkflowFile *file, WorkflowJob *job, FileRegistryService *file_registry_service=nullptr)
 Synchronously ask the storage service to delete a file copy. More...
 
virtual double getFreeSpace ()
 Synchronously asks the storage service for its capacity. More...
 
double getTotalSpace ()
 Get the total static capacity of the storage service (in zero simulation time) More...
 
virtual void initiateFileCopy (std::string answer_mailbox, WorkflowFile *file, StorageService *src, std::string src_dir, std::string dst_dir)
 Asynchronously ask the storage service to read a file from another storage service. More...
 
virtual void initiateFileRead (std::string mailbox_that_should_receive_file_content, WorkflowFile *file, std::string src_dir)
 Asynchronously read a file from the storage service. More...
 
virtual bool lookupFile (WorkflowFile *file)
 Synchronously asks the storage service whether it holds a file. More...
 
virtual bool lookupFile (WorkflowFile *file, std::string dst_dir)
 Synchronously asks the storage service whether it holds a file. More...
 
virtual bool lookupFile (WorkflowFile *file, WorkflowJob *)
 Synchronously asks the storage service whether it holds a file. More...
 
virtual void readFile (WorkflowFile *file, std::string src_dir)
 Synchronously read a file from the storage service. More...
 
virtual void readFile (WorkflowFile *file)
 Synchronously read a file from the storage service. More...
 
virtual void readFile (WorkflowFile *file, WorkflowJob *job)
 Synchronously read a file from the storage service. More...
 
void stop ()
 Stop the service.
 
virtual void writeFile (WorkflowFile *file, std::string dst_dir)
 Synchronously write a file to the storage service. More...
 
virtual void writeFile (WorkflowFile *file)
 Synchronously write a file to the storage service. More...
 
virtual void writeFile (WorkflowFile *file, WorkflowJob *job)
 Synchronously write a file to the storage service. More...
 
- Public Member Functions inherited from wrench::Service
std::string getHostname ()
 Get the name of the host on which the service is / will be running. More...
 
double getMessagePayloadValueAsDouble (std::string)
 Get a message payload of the Service as a double. More...
 
std::string getMessagePayloadValueAsString (std::string)
 Get a message payload of the Service as a string. More...
 
double getNetworkTimeoutValue ()
 Returns the service's network timeout value. More...
 
bool getPropertyValueAsBoolean (std::string)
 Get a property of the Service as a boolean. More...
 
double getPropertyValueAsDouble (std::string)
 Get a property of the Service as a double. More...
 
std::string getPropertyValueAsString (std::string)
 Get a property of the Service as a string. More...
 
bool isUp ()
 Returns true if the service is UP, false otherwise. More...
 
void setNetworkTimeoutValue (double value)
 Sets the service's network timeout value. More...
 
void setStateToDown ()
 Set the state of the service to DOWN.
 
void start (std::shared_ptr< Service > this_service, bool daemonize, bool auto_restart)
 Start the service. More...
 
- Public Member Functions inherited from wrench::S4U_Daemon
 S4U_Daemon (std::string hostname, std::string process_name_prefix, std::string mailbox_prefix)
 Constructor (daemon with a mailbox) More...
 
virtual ~S4U_Daemon ()
 Constructor (daemon without a mailbox) More...
 
virtual void cleanup ()
 Cleanup function called when the daemon terminates (for whatever reason)
 
void createLifeSaver (std::shared_ptr< S4U_Daemon > reference)
 Create a life saver for the daemon. More...
 
std::string getName ()
 Retrieve the process name. More...
 
bool hasCleanlyTerminated ()
 Returned the terminated status of the daemon/actor.
 
bool isSetToAutoRestart ()
 Return the auto-restart status of the daemon. More...
 
bool join ()
 Join (i.e., wait for) the daemon. More...
 
virtual int main ()=0
 The daemon's main method, to be overridden. More...
 
void resume ()
 Resume the daemon/actor.
 
void setCleanlyTerminated ()
 Set the terminated status of the daemon/actor.
 
void startDaemon (bool daemonized, bool auto_restart)
 Start the daemon. More...
 
void suspend ()
 Suspend the daemon/actor.
 

Static Public Member Functions

static void deleteFiles (std::set< WorkflowFile *> files, std::map< WorkflowFile *, StorageService *> file_locations, StorageService *default_storage_service)
 Synchronously and sequentially delete a set of files from storage services. More...
 
static void readFiles (std::set< WorkflowFile *> files, std::map< WorkflowFile *, StorageService *> file_locations, StorageService *default_storage_service, std::set< WorkflowFile *> &files_in_scratch, WorkflowJob *job=nullptr)
 Synchronously and sequentially read a set of files from storage services. More...
 
static void writeFiles (std::set< WorkflowFile *> files, std::map< WorkflowFile *, StorageService *> file_locations, StorageService *default_storage_service, std::set< WorkflowFile *> &files_in_scratch, WorkflowJob *job=nullptr)
 Synchronously and sequentially upload a set of files from storage services. More...
 

Protected Member Functions

void removeFileFromStorage (WorkflowFile *, std::string)
 Remove a file from storage (internal method) More...
 
void stageFile (WorkflowFile *)
 Store a file on the storage service BEFORE the simulation is launched. More...
 
- Protected Member Functions inherited from wrench::Service
 Service (std::string hostname, std::string process_name_prefix, std::string mailbox_name_prefix)
 Constructor. More...
 
void serviceSanityCheck ()
 Check whether the service is properly configured and running. More...
 
void setMessagePayload (std::string, std::string)
 Set a message payload of the Service. More...
 
void setMessagePayloads (std::map< std::string, std::string > default_messagepayload_values, std::map< std::string, std::string > overriden_messagepayload_values)
 Set default and user-defined message payloads. More...
 
void setProperties (std::map< std::string, std::string > default_property_values, std::map< std::string, std::string > overriden_property_values)
 Set default and user-defined properties. More...
 
void setProperty (std::string, std::string)
 Set a property of the Service. More...
 
- Protected Member Functions inherited from wrench::S4U_Daemon
void acquireDaemonLock ()
 Lock the daemon's lock.
 
void killActor ()
 Kill the daemon/actor.
 
void releaseDaemonLock ()
 Unlock the daemon's lock.
 
void runMainMethod ()
 Method that run's the user-defined main method (that's called by the S4U actor class)
 

Protected Attributes

double capacity
 The storage service's capacity.
 
double occupied_space = 0
 The storage service's occupied space.
 
std::map< std::string, std::set< WorkflowFile * > > stored_files
 The map of file directories and the set of files stored on those directories inside the storage service.
 
- Protected Attributes inherited from wrench::Service
std::map< std::string, std::string > messagepayload_list
 The service's messagepayload list.
 
std::string name
 The service's name.
 
double network_timeout = 30.0
 The time (in seconds) after which a service that doesn't send back a reply (control) message causes a NetworkTimeOut exception. (default: 30 second; if <0 never timeout)
 
std::map< std::string, std::string > property_list
 The service's property list.
 
State state
 The service's state.
 
- Protected Attributes inherited from wrench::S4U_Daemon
unsigned int num_starts = 0
 

Additional Inherited Members

- Public Types inherited from wrench::Service
enum  State { UP, DOWN }
 Service states. More...
 
- Public Attributes inherited from wrench::S4U_Daemon
std::string hostname
 The name of the host on which the daemon is running.
 
LifeSaver * life_saver = nullptr
 The daemon's life saver.
 
std::string mailbox_name
 The name of the daemon's mailbox.
 
std::string process_name
 The name of the daemon.
 
Simulationsimulation
 a pointer to the simulation object
 

Detailed Description

The storage service base class.

Constructor & Destructor Documentation

◆ StorageService()

wrench::StorageService::StorageService ( const std::string &  hostname,
const std::string &  service_name,
const std::string &  mailbox_name_prefix,
double  capacity 
)

Constructor.

Parameters
hostnamethe name of the host on which the service should run
service_namethe name of the storage service
mailbox_name_prefixthe mailbox name prefix
capacitythe storage capacity in bytes

Member Function Documentation

◆ copyFile() [1/3]

void wrench::StorageService::copyFile ( WorkflowFile file,
StorageService src,
std::string  src_partition,
std::string  dst_partition 
)
virtual

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

Parameters
filethe file to copy
srcthe storage service from which to read the file
src_partitionthe partition in which the file will be read
dst_partitionthe partition in which the file will be written
Exceptions
WorkflowExecutionException
std::runtime_error
std::invalid_argument

◆ copyFile() [2/3]

void wrench::StorageService::copyFile ( WorkflowFile file,
StorageService src 
)
virtual

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

Parameters
filethe file to copy
srcthe storage service from which to read the file
Exceptions
WorkflowExecutionException
std::invalid_argument

◆ copyFile() [3/3]

void wrench::StorageService::copyFile ( WorkflowFile file,
StorageService src,
WorkflowJob src_job,
WorkflowJob dst_job 
)
virtual

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

Parameters
filethe file to copy
srcthe storage service from which to read the file
src_jobthe job from whose partition we are copying this file
dst_jobthe job to whose partition we are copying this file
Exceptions
WorkflowExecutionException
std::invalid_argument

◆ deleteFile() [1/3]

void wrench::StorageService::deleteFile ( WorkflowFile file,
FileRegistryService file_registry_service = nullptr 
)
virtual

Synchronously asks the storage service to delete a file copy.

Parameters
filethe file
file_registry_servicea file registry service that should be updated once the file deletion has (successfully) completed (none if nullptr)
Exceptions
WorkflowExecutionException
std::runtime_error
std::invalid_argument

◆ deleteFile() [2/3]

void wrench::StorageService::deleteFile ( WorkflowFile file,
std::string  dst_partition,
FileRegistryService file_registry_service = nullptr 
)
virtual

Synchronously ask the storage service to delete a file copy.

Parameters
filethe file
dst_partitionthe partition in which to delete the file
file_registry_servicea file registry service that should be updated once the file deletion has (successfully) completed (none if nullptr)
Exceptions
WorkflowExecutionException
std::runtime_error
std::invalid_argument

◆ deleteFile() [3/3]

void wrench::StorageService::deleteFile ( WorkflowFile file,
WorkflowJob job,
FileRegistryService file_registry_service = nullptr 
)
virtual

Synchronously ask the storage service to delete a file copy.

Parameters
filethe file
jobthe job associated to deleting this file
file_registry_servicea file registry service that should be updated once the file deletion has (successfully) completed (none if nullptr)
Exceptions
WorkflowExecutionException
std::runtime_error
std::invalid_argument

◆ deleteFiles()

void wrench::StorageService::deleteFiles ( std::set< WorkflowFile *>  files,
std::map< WorkflowFile *, StorageService *>  file_locations,
StorageService default_storage_service 
)
static

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

Parameters
filesthe set of files to delete
file_locationsa map of files to storage services (all must be in the "/" partition of their storage services)
default_storage_servicethe storage service to use when files don't appear in the file_locations map (or nullptr if none)
Exceptions
WorkflowExecutionException
std::runtime_error

◆ getFreeSpace()

double wrench::StorageService::getFreeSpace ( )
virtual

Synchronously asks the storage service for its capacity.

Returns
The free space in bytes
Exceptions
WorkflowExecutionException
std::runtime_error

◆ getTotalSpace()

double wrench::StorageService::getTotalSpace ( )

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

Returns
capacity of the storage service (double)

◆ initiateFileCopy()

void wrench::StorageService::initiateFileCopy ( std::string  answer_mailbox,
WorkflowFile file,
StorageService src,
std::string  src_partition,
std::string  dst_partition 
)
virtual

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

Parameters
answer_mailboxthe mailbox to which a notification message will be sent
filethe file
srcthe storage service from which to read the file
src_partitionthe source partition
dst_partitionthe destination partition
Exceptions
WorkflowExecutionException
std::invalid_argument

◆ initiateFileRead()

void wrench::StorageService::initiateFileRead ( std::string  mailbox_that_should_receive_file_content,
WorkflowFile file,
std::string  src_partition 
)
virtual

Asynchronously read a file from the storage service.

Parameters
mailbox_that_should_receive_file_contentthe mailbox to which the file should be sent
filethe file
src_partitionthe partition in which the file will be read
Exceptions
WorkflowExecutionException
std::runtime_error
std::invalid_arguments

◆ lookupFile() [1/3]

bool wrench::StorageService::lookupFile ( WorkflowFile file)
virtual

Synchronously asks the storage service whether it holds a file.

Parameters
filethe file
Returns
true or false
Exceptions
WorkflowExecutionException
std::invalid_arguments

◆ lookupFile() [2/3]

bool wrench::StorageService::lookupFile ( WorkflowFile file,
std::string  dst_partition 
)
virtual

Synchronously asks the storage service whether it holds a file.

Parameters
filethe file
dst_partitionthe partition in which to perform the lookup
Returns
true or false
Exceptions
WorkflowExecutionException
std::runtime_error
std::invalid_arguments

◆ lookupFile() [3/3]

bool wrench::StorageService::lookupFile ( WorkflowFile file,
WorkflowJob job 
)
virtual

Synchronously asks the storage service whether it holds a file.

Parameters
filethe file
jobthe job for whom we are doing the look up, the file is stored in this job's partition
Returns
true or false
Exceptions
WorkflowExecutionException
std::invalid_arguments

◆ readFile() [1/3]

void wrench::StorageService::readFile ( WorkflowFile file,
std::string  src_partition 
)
virtual

Synchronously read a file from the storage service.

Parameters
filethe file
src_partitionthe partition from which to read the file
Exceptions
WorkflowExecutionException
std::runtime_error
std::invalid_arguments

◆ readFile() [2/3]

void wrench::StorageService::readFile ( WorkflowFile file)
virtual

Synchronously read a file from the storage service.

Parameters
filethe file
Exceptions
WorkflowExecutionException
std::invalid_arguments

◆ readFile() [3/3]

void wrench::StorageService::readFile ( WorkflowFile file,
WorkflowJob job 
)
virtual

Synchronously read a file from the storage service.

Parameters
filethe file
jobthe job associated to the read of the workflow file
Exceptions
WorkflowExecutionException
std::invalid_arguments

◆ readFiles()

void wrench::StorageService::readFiles ( std::set< WorkflowFile *>  files,
std::map< WorkflowFile *, StorageService *>  file_locations,
StorageService default_storage_service,
std::set< WorkflowFile *> &  files_in_scratch,
WorkflowJob job = nullptr 
)
static

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

Parameters
filesthe set of files to read
file_locationsa map of files to storage services
default_storage_servicethe storage service to use when files don't appear in the file_locations map (which must be a compute service's scratch storage)
files_in_scratchthe set of files that have been written to the default storage service (which must be a compute service's scratch storage)
jobthe job which is doing the read of the files
Exceptions
std::runtime_error
WorkflowExecutionException

◆ removeFileFromStorage()

void wrench::StorageService::removeFileFromStorage ( WorkflowFile file,
std::string  dst_partition 
)
protected

Remove a file from storage (internal method)

Parameters
filea file
dst_partitionthe partition in which the file will be deleted
Exceptions
std::runtime_error

◆ stageFile()

void wrench::StorageService::stageFile ( WorkflowFile file)
protected

Store a file on the storage service BEFORE the simulation is launched.

Parameters
filea file
Exceptions
std::invalid_argument
std::runtime_error

◆ writeFile() [1/3]

void wrench::StorageService::writeFile ( WorkflowFile file,
std::string  dst_partition 
)
virtual

Synchronously write a file to the storage service.

Parameters
filethe file
dst_partitionthe partition in which to write the file
Exceptions
WorkflowExecutionException
std::runtime_error

◆ writeFile() [2/3]

void wrench::StorageService::writeFile ( WorkflowFile file)
virtual

Synchronously write a file to the storage service.

Parameters
filethe file
Exceptions
WorkflowExecutionException

◆ writeFile() [3/3]

void wrench::StorageService::writeFile ( WorkflowFile file,
WorkflowJob job 
)
virtual

Synchronously write a file to the storage service.

Parameters
filethe file
jobthe job associated to the write of the workflow file
Exceptions
WorkflowExecutionException

◆ writeFiles()

void wrench::StorageService::writeFiles ( std::set< WorkflowFile *>  files,
std::map< WorkflowFile *, StorageService *>  file_locations,
StorageService default_storage_service,
std::set< WorkflowFile *> &  files_in_scratch,
WorkflowJob job = nullptr 
)
static

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

Parameters
filesthe set of files to write
file_locationsa map of files to storage services
default_storage_servicethe storage service to use when files don't appear in the file_locations map (which must be a compute service's scratch storage)
files_in_scratchthe set of files that have been writted to the default storage service (which must be a compute service's scratch storage)
jobthe job which is doing the write of the files
Exceptions
std::runtime_error
WorkflowExecutionException

The documentation for this class was generated from the following files:
  • /Users/rafsilva/Documents/isi/workspace/wrench/wrench/include/wrench/services/storage/StorageService.h
  • /Users/rafsilva/Documents/isi/workspace/wrench/wrench/src/wrench/services/storage/StorageService.cpp