Skip to content

Commit

Permalink
tmp commit (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Sep 27, 2019
1 parent c3f266b commit 662a3ec
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace wrench {
return not FileLocation::operator==(rhs);
}

static std::string sanitizePath(std::string path);

private:

Expand All @@ -68,7 +69,6 @@ namespace wrench {
std::string mount_point;
std::string absolute_path_at_mount_point;

static std::string sanitizePath(std::string path);

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ namespace wrench {
"bare_metal",
scratch_space_mount_point) {


initiateInstance(hostname,
std::move(compute_resources),
std::move(property_list), std::move(messagepayload_list), DBL_MAX, nullptr);
Expand Down
18 changes: 12 additions & 6 deletions src/wrench/services/storage/simple/SimpleStorageService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,19 @@ namespace wrench {
// Figure out whether this succeeds or not
std::shared_ptr<FailureCause> failure_cause = nullptr;

auto fs = this->file_systems[location->getAbsolutePathAtMountPoint()].get();
if (this->file_systems.find(location->getAbsolutePathAtMountPoint()) == this->file_systems.end()) {
failure_cause = std::shared_ptr<FailureCause>(new FileNotFound(file, location));
} else {

if ((not fs->doesDirectoryExist(location->getAbsolutePathAtMountPoint())) or
(not fs->isFileInDirectory(file, location->getAbsolutePathAtMountPoint()))) {
WRENCH_INFO("Received a a read request for a file I don't have (%s)", location->toString().c_str());
failure_cause = std::shared_ptr<FailureCause>(
new FileNotFound(file, location));
auto fs = this->file_systems[location->getAbsolutePathAtMountPoint()].get();


if ((not fs->doesDirectoryExist(location->getAbsolutePathAtMountPoint())) or
(not fs->isFileInDirectory(file, location->getAbsolutePathAtMountPoint()))) { WRENCH_INFO(
"Received a a read request for a file I don't have (%s)", location->toString().c_str());
failure_cause = std::shared_ptr<FailureCause>(
new FileNotFound(file, location));
}
}

bool success = (failure_cause == nullptr);;
Expand Down
26 changes: 19 additions & 7 deletions src/wrench/services/storage/storage_helpers/LocicalFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include <wrench-dev.h>
#include "LogicalFileSystem.h"

WRENCH_LOG_NEW_DEFAULT_CATEGORY(logical_file_system, "Log category for Logical File System");


namespace wrench {

std::set<std::string> LogicalFileSystem::mount_points;
Expand All @@ -24,23 +27,32 @@ namespace wrench {
if (mount_point.at(0) != '/') {
mount_point = "/" + mount_point;
}
if (mount_point.at(mount_point.length()) != '/') {
if (mount_point.at(mount_point.length()-1) != '/') {
mount_point += "/";
}

mount_point = FileLocation::sanitizePath(mount_point);

// WRENCH_INFO("NEW %s", mount_point.c_str());
// Check uniqueness
if (LogicalFileSystem::mount_points.find(hostname+":"+mount_point) != LogicalFileSystem::mount_points.end()) {
throw std::invalid_argument("LogicalFileSystem::LogicalFileSystem(): A FileSystem with mount point " +
mount_point + " at host " + hostname + " already exists");
}
// Check non-proper-prefixness
for (auto const &mp : LogicalFileSystem::mount_points) {
if ((mp.find(hostname+":"+mount_point) == 0) or ((hostname+":"+mount_point).find(mp) == 0)) {
throw std::invalid_argument("LogicalFileSystem::LogicalFileSystem(): An existing mount point that "
"has as prefix or is a prefix of '" + mount_point +
"' already exists at" + "host " + hostname);

if (mount_point != "/") { // "/" is obviously a prefix, but it's okstr(),

// Check non-proper-prefixness
for (auto const &mp : LogicalFileSystem::mount_points) {
if (mp == hostname+":"+"/") {
continue; // "/" is obviously a prefix, but it's ok
}
// WRENCH_INFO("COMPARING %s TO %s", (hostname + ":" + mount_point).c_str(), mp.c_str());
if ((mp.find(hostname + ":" + mount_point) == 0) or ((hostname + ":" + mount_point).find(mp) == 0)) {
throw std::invalid_argument("LogicalFileSystem::LogicalFileSystem(): An existing mount point that "
"has as prefix or is a prefix of '" + mount_point +
"' already exists at host " + hostname);
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/wrench/simgrid_S4U_util/S4U_Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,23 +682,29 @@ namespace wrench {
*/
double S4U_Simulation::getDiskCapacity(std::string hostname, std::string mount_point) {

// WRENCH_INFO("==== %s %s ==== ", hostname.c_str(), mount_point.c_str());
simgrid::s4u::Host *host;
try {
host = simgrid::s4u::Host::by_name(hostname);
} catch (std::exception &e) {
throw std::invalid_argument("S4U_Simulation::getDiskCapacity(): Unknown host " + hostname);
}

mount_point = FileLocation::sanitizePath(mount_point + "/");

for (auto const &d : host->get_disks()) {


// Get the disk's mount point
const char *mp = d->get_property("mount");
if (!mp) {
mp = "/";
}

std::string dmp = FileLocation::sanitizePath(std::string(mp) + "/");

// This is not the mount point you're looking for
if (strcmp(mp, mount_point.c_str()) != 0) {
if (dmp != mount_point) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MessageConstructorTest : public ::testing::Test {
task = workflow->addTask("task", 1, 1, 1, 1.0, 0);
file = workflow->addFile("file", 1);
storage_service = std::shared_ptr<wrench::StorageService>((wrench::StorageService *)(1234), [](void *ptr){});
location = wrench::FileLocation::LOCATION(storage_service, "/");
location = std::shared_ptr<wrench::FileLocation>((wrench::FileLocation *)1234);
compute_service = std::shared_ptr<wrench::ComputeService>((wrench::ComputeService *)(1234), [](void *ptr){});
network_proximity_service = std::shared_ptr<wrench::NetworkProximityService>((wrench::NetworkProximityService *)(1234), [](void *ptr){});
network_proximity_daemon = std::shared_ptr<wrench::NetworkProximityDaemon>((wrench::NetworkProximityDaemon *)(1234), [](void *ptr){});
Expand Down
2 changes: 1 addition & 1 deletion test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
int main(int argc, char **argv) {

// disable log
xbt_log_control_set("root.thresh:critical");
// xbt_log_control_set("root.thresh:critical");

// Example selective log enabling
// xbt_log_control_set("simulation_timestamps.thresh:debug");
Expand Down
25 changes: 13 additions & 12 deletions test/workflow/WorkflowTaskTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ class WorkflowTaskTest : public ::testing::Test {
" <zone id=\"AS0\" routing=\"Full\"> "
" <host id=\"WMSHost\" speed=\"1f\" core=\"1\">"
" <disk id=\"large_disk\" read_bw=\"100MBps\" write_bw=\"40MBps\">"
" <prop id=\"size\" value=\"100000000000000\"/>"
" <prop id=\"size\" value=\"100000000000000B\"/>"
" <prop id=\"mount\" value=\"/\"/>"
" </disk>"
" </host>"
" <disk id=\"other_large_disk\" read_bw=\"100MBps\" write_bw=\"40MBps\">"
" <prop id=\"size\" value=\"100000000000000\"/>"
" <prop id=\"size\" value=\"100000000000000B\"/>"
" <prop id=\"mount\" value=\"/backup\"/>"
" </disk>"
" </host>"
Expand Down Expand Up @@ -316,18 +315,20 @@ void WorkflowTaskTest::do_WorkflowTaskExecutionHistory_test() {

ASSERT_NO_THROW(simulation->instantiatePlatform(platform_file_path));

std::string wms_host = simulation->getHostnameList()[1];
std::string execution_host = simulation->getHostnameList()[0];
std::string wms_host = "WMSHost";
std::string execution_host = "ExecutionHost";

ASSERT_NO_THROW(compute_service = simulation->add(new wrench::BareMetalComputeService(wms_host,
{std::make_pair(
execution_host,
std::make_tuple(
wrench::ComputeService::ALL_CORES,
wrench::ComputeService::ALL_RAM))},
{})));
ASSERT_NO_THROW(compute_service = simulation->add(new wrench::BareMetalComputeService(
wms_host,
{std::make_pair(
execution_host,
std::make_tuple(
wrench::ComputeService::ALL_CORES,
wrench::ComputeService::ALL_RAM))}, "",
{})));

ASSERT_NO_THROW(storage_service = simulation->add(new wrench::SimpleStorageService(wms_host, {"/"})));

ASSERT_NO_THROW(
backup_storage_service = simulation->add(new wrench::SimpleStorageService(wms_host, {"/backup"})));

Expand Down

0 comments on commit 662a3ec

Please sign in to comment.