Skip to content

Commit

Permalink
(#2) passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Oct 10, 2019
1 parent c4e4c64 commit ee67c05
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/wrench/services/storage/StorageService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ namespace wrench {

try {
for (auto mp : mount_points) {
this->file_systems[mp] = std::unique_ptr<LogicalFileSystem>(new LogicalFileSystem(hostname, mp));
this->file_systems[mp] = std::unique_ptr<LogicalFileSystem>(
new LogicalFileSystem(this->getHostname(), this->getName(), mp));
}
} catch (std::invalid_argument &e) {
throw;
Expand Down
8 changes: 5 additions & 3 deletions src/wrench/services/storage/simple/SimpleStorageService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ namespace wrench {
}


std::string message = "Simple Storage service %s starting on host %s:";
std::string message = "Simple Storage service " + this->getName() +
" starting on host " + this->getHostname();
for (auto const &fs : this->file_systems) {
message += "\n\t- " + fs.first + ": " + std::to_string(fs.second->getFreeSpace()/(1000*1000*1000)) + "/" +
std::to_string(fs.second->getTotalCapacity()/(1000*1000*1000)) + "GB";
message += "\n\t- " + fs.first + ": " +
std::to_string(fs.second->getFreeSpace()) + "/" +
std::to_string(fs.second->getTotalCapacity()) + " Bytes";
}
WRENCH_INFO("%s", message.c_str());

Expand Down
23 changes: 15 additions & 8 deletions src/wrench/services/storage/storage_helpers/LogicalFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ WRENCH_LOG_NEW_DEFAULT_CATEGORY(logical_file_system, "Log category for Logical F

namespace wrench {

std::set<std::string> LogicalFileSystem::mount_points;
std::map<std::string, std::string> LogicalFileSystem::mount_points;

/**
* @brief Constructor
* @param hostname: the host on which the file system is located
* @param ss_name: the storage service this file system is for
* @param mount_point: the mount point
*/
LogicalFileSystem::LogicalFileSystem(std::string hostname, std::string mount_point) {
LogicalFileSystem::LogicalFileSystem(std::string hostname, std::string ss_name, std::string mount_point) {

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

Expand All @@ -35,11 +37,11 @@ namespace wrench {

// Check non-proper-prefixness
for (auto const &mp : LogicalFileSystem::mount_points) {
if (mp == hostname+":"+"/") {
if (mp.first == 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)) {
if ((mp.first.find(hostname + ":" + mount_point) == 0) or ((hostname + ":" + mount_point).find(mp.first) == 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 All @@ -50,6 +52,7 @@ namespace wrench {


this->hostname = hostname;
this->ss_name = ss_name;
this->mount_point = mount_point;
this->content["/"] = {};
this->total_capacity = S4U_Simulation::getDiskCapacity(hostname, mount_point);
Expand All @@ -64,11 +67,15 @@ namespace wrench {
*/
void LogicalFileSystem::init() {
// Check uniqueness
if (LogicalFileSystem::mount_points.find(hostname+":"+mount_point) != LogicalFileSystem::mount_points.end()) {
throw std::invalid_argument("LogicalFileSystem::init(): A FileSystem with mount point " +
mount_point + " at host " + hostname + " already exists");

if (LogicalFileSystem::mount_points.find(this->hostname + ":" + this->mount_point)
!= LogicalFileSystem::mount_points.end()) {
if (LogicalFileSystem::mount_points[this->hostname + ":" + this->mount_point] != this->ss_name) {
throw std::invalid_argument("LogicalFileSystem::init(): A FileSystem with mount point " +
this->mount_point + " at host " + this->hostname + " already exists");
}
}
LogicalFileSystem::mount_points.insert(hostname+":"+mount_point);
LogicalFileSystem::mount_points[this->hostname + ":" + this->mount_point] = this->ss_name;
this->initialized = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace wrench {

public:

explicit LogicalFileSystem(std::string hostname, std::string mount_point);
explicit LogicalFileSystem(std::string hostname, std::string ss_name, std::string mount_point);

void init();

Expand Down Expand Up @@ -55,10 +55,11 @@ namespace wrench {

void stageFile(WorkflowFile *file, std::string absolute_path);

static std::set<std::string> mount_points;
static std::map<std::string, std::string> mount_points;


std::string hostname;
std::string ss_name;
std::string mount_point;
double total_capacity;
double occupied_space;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,6 @@ void VirtualizedClusterServiceTest::do_VMMigrationTest_test() {

// Create a Virtualized Cluster Service
std::vector<std::string> execution_hosts = wrench::Simulation::getHostnameList();
try {compute_service = simulation->add(
new wrench::VirtualizedClusterComputeService(hostname, execution_hosts, "/scratch",
{{wrench::BareMetalComputeServiceProperty::SUPPORTS_PILOT_JOBS,
"false"}}));
} catch (std::invalid_argument &e) {
WRENCH_INFO("---> %s", e.what());
}


ASSERT_NO_THROW(compute_service = simulation->add(
new wrench::VirtualizedClusterComputeService(hostname, execution_hosts, "/scratch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,7 @@ void ComprehensiveIntegrationHostFailuresTest::do_IntegrationFailureTest_test(st
simulation->init(&argc, argv);

// Setting up the platform
WRENCH_INFO("HERE");
ASSERT_NO_THROW(simulation->instantiatePlatform(platform_file_path));
WRENCH_INFO("DONE!");

// Create Storage Services
if (args.find("storage1") != args.end()) {
Expand Down

0 comments on commit ee67c05

Please sign in to comment.