Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Oct 16, 2024
1 parent 07246f7 commit 41f0542
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 25 deletions.
4 changes: 2 additions & 2 deletions include/wrench/data_file/DataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace wrench {
class DataFile {

public:
sg_size_t getSize() const;
[[nodiscard]] sg_size_t getSize() const;
void setSize(sg_size_t size);
std::string getID() const;
[[nodiscard]] std::string getID() const;
~DataFile();

protected:
Expand Down
1 change: 0 additions & 1 deletion include/wrench/services/storage/StorageService.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "wrench/services/Service.h"
#include "wrench/services/file_registry/FileRegistryService.h"
#include "wrench/job/StandardJob.h"
//#include "wrench/services/storage/storage_helpers/LogicalFileSystem.h"
#include "wrench/services/storage/storage_helpers/FileLocation.h"

namespace wrench {
Expand Down
7 changes: 5 additions & 2 deletions include/wrench/simgrid_S4U_util/S4U_Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ namespace wrench {
static sg_size_t getHostMemoryCapacity(simgrid::s4u::Host *host);

private:
static void traverseAllNetZonesRecursive(simgrid::s4u::NetZone *nz, std::map<std::string, std::vector<std::string>> &result, bool get_subzones, bool get_clusters, bool get_hosts_from_zones, bool get_hosts_from_clusters);
static void traverseAllNetZonesRecursive(simgrid::s4u::NetZone *nz, std::map<std::string,
std::vector<std::string>> &result,
bool get_subzones, bool get_clusters,
bool get_hosts_from_zones, bool get_hosts_from_clusters);

simgrid::s4u::Engine *engine;
simgrid::s4u::Engine *engine = nullptr;
bool initialized = false;
bool platform_setup = false;
};
Expand Down
9 changes: 3 additions & 6 deletions src/wrench/action/FileReadAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace wrench {
* @brief Constructor
* @param name: the action's name (if empty, a unique name will be picked for you)
* @param file_locations: the locations to read from (will be tried in order until one succeeds)
* @param num_bytes_to_read: the number of bytes to read (if == 0: read the whole file)
* @param num_bytes_to_read: the number of bytes to read
*/
FileReadAction::FileReadAction(const std::string &name,
std::vector<std::shared_ptr<FileLocation>> file_locations,
Expand All @@ -42,13 +42,10 @@ namespace wrench {
}
}

if (num_bytes_to_read == 0) {
this->num_bytes_to_read = this->file->getSize();
} else if (num_bytes_to_read <= this->file->getSize()) {
this->num_bytes_to_read = num_bytes_to_read;
} else {
if (num_bytes_to_read > this->file->getSize()) {
throw std::invalid_argument("FileReadAction::FileReadAction(): cannot create a file read action that would read more bytes than the file size");
}
this->num_bytes_to_read = num_bytes_to_read;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/wrench/job/CompoundJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace wrench {
* @param name: the action's name (if empty, a unique name will be picked for you)
* @param file: the file to read
* @param storage_service: the storage service to read the file from
* @param num_bytes_to_read: the number of bytes to read (if 0, read the whole file)
* @param num_bytes_to_read: the number of bytes to read
* @return a file read action
*/
std::shared_ptr<FileReadAction> CompoundJob::addFileReadAction(const std::string &name,
Expand Down Expand Up @@ -201,14 +201,14 @@ namespace wrench {
std::shared_ptr<FileReadAction> CompoundJob::addFileReadAction(const std::string &name,
const std::shared_ptr<FileLocation> &file_location) {
std::vector<std::shared_ptr<FileLocation>> v = {file_location};
return this->addFileReadAction(name, v, 0);
return this->addFileReadAction(name, v, file_location->getFile()->getSize());
}

/**
* @brief Add a file read action to the job
* @param name: the action's name (if empty, a unique name will be picked for you)
* @param file_location: the file's location
* @param num_bytes_to_read: the number of bytes to read (if zero, read the whole file)
* @param num_bytes_to_read: the number of bytes to read
* @return a file read action
*/
std::shared_ptr<FileReadAction> CompoundJob::addFileReadAction(const std::string &name,
Expand All @@ -234,7 +234,7 @@ namespace wrench {
* @brief Add a file read action to the job
* @param name: the action's name (if empty, a unique name will be picked for you)
* @param file_locations: the locations to read the file from (will be tried in order until one succeeds)
* @param num_bytes_to_read: number of bytes to read (if zero, read the whole file)
* @param num_bytes_to_read: number of bytes to read
* @return a file read action
*/
std::shared_ptr<FileReadAction> CompoundJob::addFileReadAction(const std::string &name,
Expand Down
3 changes: 0 additions & 3 deletions src/wrench/services/compute/ComputeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ WRENCH_LOG_CATEGORY(wrench_core_compute_service, "Log category for Compute Servi

namespace wrench {

constexpr unsigned long ComputeService::ALL_CORES;
constexpr double ComputeService::ALL_RAM;

/**
* @brief Stop the compute service
*/
Expand Down
1 change: 0 additions & 1 deletion src/wrench/services/file_registry/FileRegistryService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <wrench/data_file/DataFile.h>
#include <wrench/exceptions/ExecutionException.h>
#include <wrench/services/network_proximity/NetworkProximityService.h>
#include <wrench/failure_causes/NetworkError.h>

WRENCH_LOG_CATEGORY(wrench_core_file_registry_service,
"Log category for File Registry Service");
Expand Down
12 changes: 6 additions & 6 deletions src/wrench/services/storage/xrootd/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace wrench {
} catch (ExecutionException &e) {
WRENCH_INFO(
"Got a network error while getting some message... ignoring");
return true;// oh well
return true;// oh! well
}

WRENCH_DEBUG("Got a [%s] message", message->getName().c_str());
Expand Down Expand Up @@ -447,7 +447,7 @@ namespace wrench {
metavisor->defaultTimeToLive));
}
}
} else {// you asked a leaf directly and it didn't have the file
} else {// you asked a leaf directly, and it didn't have the file
msg->answer_commport->putMessage(new StorageServiceFileReadAnswerMessage(
FileLocation::LOCATION(internalStorage, file),
false,
Expand Down Expand Up @@ -962,8 +962,8 @@ namespace wrench {
}
// Replace the location with
// TODO: THIS LOCATION REWRITE WAS DONE TO FIX SOMETHING BUT HENRI HAS NO
// TODO: IDEA HOW COME IT'S EVER WORKED BEFORE SINCE THE FTT INSIDE THE INTERNALSTORAGE
// TODO: WILL SAY "THIS IS NOT ME, MY PARENT IS THE INTERNALSTORAGE, NOT THE NODE"
// TODO: IDEA HOW COME IT'S EVER WORKED BEFORE SINCE THE FTT INSIDE THE INTERNAL STORAGE
// TODO: WILL SAY "THIS IS NOT ME, MY PARENT IS THE INTERNAL STORAGE, NOT THE NODE"
auto new_location = FileLocation::LOCATION(internalStorage, location->getDirectoryPath(), location->getFile());
internalStorage->writeFile(answer_commport, new_location, num_bytes_to_write, wait_for_answer);
// internalStorage->writeFile(answer_commport, location, wait_for_answer);
Expand Down Expand Up @@ -1013,9 +1013,9 @@ namespace wrench {
bool Node::hasFile(const shared_ptr<FileLocation> &location) {
if (internalStorage)
return internalStorage->hasFile(location);
//return false;//no internal storage here, so I dont have any files. But I am pretending to have some, so it's reasonable to ask.
//return false;//no internal storage here, so I don't have any files. But I am pretending to have some, so it's reasonable to ask.
//alternatively
return !constructFileSearchTree(metavisor->getFileNodes(location->getFile())).empty();//meta search the subtree for the file. If its in the subtree we can find a route to it, so we have it
return !constructFileSearchTree(metavisor->getFileNodes(location->getFile())).empty();//meta-search the subtree for the file. If it's in the subtree we can find a route to it, so we have it
}

/**
Expand Down

0 comments on commit 41f0542

Please sign in to comment.