Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Jun 27, 2024
1 parent 08f4c18 commit 563eb79
Show file tree
Hide file tree
Showing 16 changed files with 1,415 additions and 1,411 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ endif ()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/conf/cmake/")
find_package(Boost REQUIRED)
find_package(SimGrid REQUIRED)
find_package(FSMod REQUIRED)

find_package(nlohmann_json)

Expand Down
2 changes: 1 addition & 1 deletion include/wrench/services/storage/StorageService.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ namespace wrench {
* @param location: a location
**/
virtual void incrementNumRunningOperationsForLocation(const std::shared_ptr<FileLocation> &location) {
// no nothing
// do nothing
}

/***********************/
Expand Down
2 changes: 2 additions & 0 deletions include/wrench/services/storage/StorageServiceProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace wrench {

/** @brief The caching behavior. Possible values are:
* - "NONE" (default): no caching, i.e., if not enough space is available for a new file, then the file write/creation fails.
* - "FIFO": FIFO policy, i.e., if not enough space is available for a new file, the oldest
* files are deleted until enough space is available.
* - "LRU": Least Recently Used policy, i.e., if not enough space is available for a new file, the Least Recently Used
* files are deleted until enough space is available.
**/
Expand Down
70 changes: 41 additions & 29 deletions include/wrench/services/storage/simple/SimpleStorageService.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "wrench/services/memory/MemoryManager.h"
#include "wrench/simgrid_S4U_util/S4U_PendingCommunication.h"
#include "wrench/simgrid_S4U_util/S4U_CommPort.h"
#include <fsmod.hpp>

namespace wrench {

Expand Down Expand Up @@ -107,42 +108,53 @@ namespace wrench {

double getTotalFilesZeroTime() override;

virtual std::string getBaseRootPath() override;
std::string getBaseRootPath() override;

/**
* @brief Reserve space at the storage service
* @param location: a location
* @return true if success, false otherwise
*/
virtual bool reserveSpace(std::shared_ptr<FileLocation> &location) override {
std::string mount_point;
std::string path_at_mount_point;
this->splitPath(location->getPath(), mount_point, path_at_mount_point);
return this->file_systems[mount_point]->reserveSpace(location->getFile(), path_at_mount_point);
bool reserveSpace(std::shared_ptr<FileLocation> &location) override {
// THIS SHOULD NO LONGER BE USED? AND INSTEAD WE SHOULD CREATE A DOT FILE WITH SET SIZE
// AND REMOVE OR MOVE IT WHENEVER FAILED / CREATED
// Just create the file on the file system, tentatively
// TODO: Should this be marked unevictable by caching???
try {
this->file_system->create_file(location->getPath(), (sg_size_t) location->getFile()->getSize());
} catch (simgrid::Exception &ignore) {
return false;
}
return true;
}

/**
* @brief Unreserve space at the storage service
* @param location: a location
*/
virtual void unreserveSpace(std::shared_ptr<FileLocation> &location) override {
std::string mount_point;
std::string path_at_mount_point;
this->splitPath(location->getPath(), mount_point, path_at_mount_point);
this->file_systems[mount_point]->unreserveSpace(location->getFile(), path_at_mount_point);
void unreserveSpace(std::shared_ptr<FileLocation> &location) override {
// Just remove the file from the file system
if (this->file_system->file_exists(location->getPath())) {
throw std::runtime_error("Calling unreserveSpace() on a location for which reserveSpace() likely wasn't allocated");
}
this->file_system->unlink_file(location->getPath());
// std::string mount_point;
// std::string path_at_mount_point;
// this->splitPath(location->getPath(), mount_point, path_at_mount_point);
// this->file_systems[mount_point]->unreserveSpace(location->getFile(), path_at_mount_point);
}

/**
* @brief Get the mount point that stores a path
* @param path: path
*
* @return a mount point
*/
std::string getPathMountPoint(const std::string &path) {
std::string mount_point, path_at_mount_point;
this->splitPath(path, mount_point, path_at_mount_point);
return mount_point;
}
// /**
// * @brief Get the mount point that stores a path
// * @param path: path
// *
// * @return a mount point
// */
// std::string getPathMountPoint(const std::string &path) {
// std::string mount_point, path_at_mount_point;
// this->splitPath(path, mount_point, path_at_mount_point);
// return mount_point;
// }

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

Expand All @@ -162,22 +174,22 @@ namespace wrench {
* @brief Determine whether the storage service is bufferized
* @return true if bufferized, false otherwise
*/
virtual bool isBufferized() const override {
bool isBufferized() const override {
return this->is_bufferized;
}

/**
* @brief Determine the storage service's buffer size
* @return a size in bytes
*/
virtual double getBufferSize() const override {
double getBufferSize() const override {
return this->buffer_size;
}


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

virtual void incrementNumRunningOperationsForLocation(const std::shared_ptr<FileLocation> &location) override;
void incrementNumRunningOperationsForLocation(const std::shared_ptr<FileLocation> &location) override;
/***********************/
/** \endcond **/
/***********************/
Expand Down Expand Up @@ -214,10 +226,10 @@ namespace wrench {
/** @brief Whether the service is bufferized */
bool is_bufferized;

/** @brief File systems */
std::map<std::string, std::unique_ptr<LogicalFileSystem>> file_systems;
/** @brief File system */
std::shared_ptr<simgrid::fsmod::FileSystem> file_system;

bool splitPath(const std::string &path, std::string &mount_point, std::string &path_at_mount_point);
// bool splitPath(const std::string &path, std::string &mount_point, std::string &path_at_mount_point);

/***********************/
/** \endcond **/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <unordered_map>
#include <simgrid/s4u.hpp>

#include <wrench/data_file/DataFile.h>


namespace wrench {

Expand All @@ -25,7 +27,6 @@ namespace wrench {

class StorageService;
class SimpleStorageService;
class DataFile;

/**
* @brief A class that encodes a file location
Expand Down
Loading

0 comments on commit 563eb79

Please sign in to comment.