Skip to content

Commit

Permalink
tmp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Oct 1, 2024
1 parent 883c40c commit a80708d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
12 changes: 6 additions & 6 deletions include/wrench/services/storage/StorageService.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace wrench {
* @return true if the file is present, or false
*/
bool lookupFile(const std::shared_ptr<DataFile> &file) {
return this->lookupFile(file, "/");
return this->lookupFile(wrench::FileLocation::LOCATION(this->getSharedPtr<StorageService>(), file));
}
/**
* @brief Lookup whether a file exists on the storage service (incurs simulated overheads)
Expand Down Expand Up @@ -100,7 +100,7 @@ namespace wrench {
* @param file a file
*/
void deleteFile(const std::shared_ptr<DataFile> &file) {
this->deleteFile(file, "/");
this->deleteFile(wrench::FileLocation::LOCATION(this->getSharedPtr<StorageService>(), file));
}
/**
* @brief Delete a file at the storage service (incurs simulated overheads)
Expand Down Expand Up @@ -243,7 +243,7 @@ namespace wrench {
* @return true if the file is present, false otherwise
*/
bool hasFile(const std::shared_ptr<DataFile> &file) {
return this->hasFile(file, "/");
return this->hasFile(wrench::FileLocation::LOCATION(this->getSharedPtr<StorageService>(), file));
}
/**
* @brief Determines whether a file is present at the storage service (in zero simulated time)
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace wrench {
* @param file: a file
*/
void removeFile(const std::shared_ptr<DataFile> &file) {
this->removeFile(file, "/");
this->removeFile(wrench::FileLocation::LOCATION(this->getSharedPtr<StorageService>(), file));
}
/**
* @brief Remove a file at the storage service (in zero simulated time)
Expand Down Expand Up @@ -370,7 +370,7 @@ namespace wrench {
* @return a date in seconds
*/
double getFileLastWriteDate(const std::shared_ptr<DataFile> &file) {
return this->getFileLastWriteDate(file, "/");
return this->getFileLastWriteDate(wrench::FileLocation::LOCATION(this->getSharedPtr<StorageService>(), file));
}
/**
* @brief Get a file's last write date at the storage service (in zero simulated time)
Expand Down Expand Up @@ -442,7 +442,7 @@ namespace wrench {
* @return a path
*/
virtual std::string getBaseRootPath() {
return "/";
throw std::runtime_error("StorageService::traceTotalFiles: should have been overridden by derived class");
}

/**
Expand Down
14 changes: 5 additions & 9 deletions src/wrench/services/storage/simple/SimpleStorageService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ namespace wrench {
const std::shared_ptr<FileLocation> &location,
S4U_CommPort *answer_commport) {

std::cerr << "LOOKING FOR FILE: " << location->getFilePath() << "\n";
bool file_found = this->file_system->file_exists(location->getFilePath());

answer_commport->dputMessage(
Expand Down Expand Up @@ -457,7 +458,6 @@ namespace wrench {
void SimpleStorageService::createFile(const std::shared_ptr<FileLocation> &location) {
std::string full_path = location->getFilePath();

std::cerr << "IN CREATE FILE SIMPLeSTORAGESERVOCE: " << full_path << "\n";
try {
this->file_system->create_file(full_path, location->getFile()->getSize());
} catch (sgfs::FileAlreadyExistsException &e) {
Expand Down Expand Up @@ -543,8 +543,6 @@ namespace wrench {
return std::shared_ptr<FailureCause>(new InvalidDirectoryPath(location));
}

std::cerr << "IN VALIDATE FILE WRITE 1: " << partition->get_free_space() << "\n";

bool file_already_there = this->file_system->file_exists(location->getFilePath());
try {
if (not file_already_there) { // Open dot file
Expand All @@ -571,8 +569,6 @@ namespace wrench {
new StorageServiceNotEnoughSpace(
file,
this->getSharedPtr<SimpleStorageService>()));
} catch (simgrid::Exception &e) {
std::cerr << "WRTF!@#!" << e.what() << "\n";
}
// std::cerr << "IN VALIDATE FILE WRITE 2: " << partition->get_free_space() << "\n";
return nullptr;
Expand Down Expand Up @@ -618,12 +614,12 @@ namespace wrench {
if (not dst_file_already_there) { // Open dot file
// std::cerr << "FILE NOT ALREADY THERE, OPENING A DOT FILE \n";
std::string dot_file_path = dst_location->getADotFilePath();
this->file_system->create_file(dot_file_path, dst_location->getFile()->getSize());
dst_opened_file = this->file_system->open(dot_file_path, "r+");
dst_file_system->create_file(dot_file_path, dst_location->getFile()->getSize());
dst_opened_file = dst_file_system->open(dot_file_path, "r+");
dst_opened_file->seek(0, SEEK_SET);
} else { // Open the file
// std::cerr << "FILE ALREADY THERE, JUST OPENING IT\n";
dst_opened_file = this->file_system->open(dst_location->getFilePath(), "r+");
dst_opened_file = dst_file_system->open(dst_location->getFilePath(), "r+");
dst_opened_file->seek(0, SEEK_SET);
}
} catch (simgrid::fsmod::NotEnoughSpaceException &e) {
Expand All @@ -632,7 +628,7 @@ namespace wrench {
}

// Open source file
src_opened_file = this->file_system->open(src_location->getFilePath(), "r");
src_opened_file = src_file_system->open(src_location->getFilePath(), "r");

return nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ namespace wrench {


std::shared_ptr<simgrid::fsmod::File> opened_file;
std::cerr << "BEFORE VALIDATION\n";
auto failure_cause = validateFileWriteRequest(location, num_bytes_to_write, opened_file);
std::cerr << "AFTER VALIDATION: " << this->file_system->get_partitions().at(0)->get_free_space() << "\n";


if (failure_cause) {
Expand Down Expand Up @@ -337,6 +335,8 @@ namespace wrench {
std::shared_ptr<FileLocation> &dst_location,
S4U_CommPort *answer_commport) {

std::cerr << "IN BUFFERED PROCESS FILE COPY REQUEST\n";

std::shared_ptr<simgrid::fsmod::File> src_opened_file;
std::shared_ptr<simgrid::fsmod::File> dst_opened_file;
auto failure_cause = validateFileCopyRequest(src_location, dst_location, src_opened_file, dst_opened_file);
Expand Down Expand Up @@ -455,7 +455,6 @@ namespace wrench {
}
// Deal with possibly opened destination file
if (ftt->dst_opened_file) {
std::cerr << "THERE WAS AN OPENED DST FILE, JUST CLOSE IT!\n";
auto dst_file_system = ftt->dst_opened_file->get_file_system();
auto dst_file_path = ftt->dst_opened_file->get_path();
ftt->dst_opened_file->close();
Expand Down Expand Up @@ -548,6 +547,8 @@ namespace wrench {
SimpleStorageServiceMessagePayload::FILE_COPY_ANSWER_MESSAGE_PAYLOAD)));
}

std::cerr << "DONE WITH FILE TRANSFER THREAD\n";

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ namespace wrench {
*/
void SimpleStorageServiceNonBufferized::processTransactionCompletion(const std::shared_ptr<Transaction> &transaction) {

std::cerr << "IN TRANSACTION COMPLETION\n";

// Deal with possibly open source file
if (transaction->src_opened_file) {
std::cerr << "THERE WAS AN OPENED SOURCE FILE, WHICH I AM CLOSING\n";
Expand All @@ -82,6 +80,7 @@ namespace wrench {
if (not dst_file_system->file_exists(transaction->dst_location->getFilePath())) {
std::cerr << transaction->dst_location->getStorageService()->getName() << ": MOVING " << dst_file_path << " TO " << transaction->dst_location->getFilePath() << "\n";
dst_file_system->move_file(dst_file_path, transaction->dst_location->getFilePath());
std::cerr << "DONE THE MOVE\n";
}
}

Expand Down Expand Up @@ -130,6 +129,7 @@ namespace wrench {
this->getMessagePayloadValue(
SimpleStorageServiceMessagePayload::FILE_COPY_ANSWER_MESSAGE_PAYLOAD)));
}
std::cerr << "DONE WITH TRANSACTION!\n";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ namespace wrench {
if (!dst_ss) {
throw std::runtime_error("FileTransferThread::receiveFileFromNetwork(): Storage Service should be a SimpleStorageService for disk write");
}
std::cerr << "WRITING A CHUNK TO THE DISK!\n";
this->dst_opened_file->write(msg->payload);
std::cerr << "DONE WRITING TO THE DISK!\n";
// simulation->writeToDisk(msg->payload, location->getStorageService()->hostname,
// dst_location->getDiskOrNull());
#ifdef PAGE_CACHE_SIMULATION
Expand Down Expand Up @@ -368,7 +366,6 @@ namespace wrench {
throw std::runtime_error("FileTransferThread::receiveFileFromNetwork(): Writing to disk can only be to a SimpleStorageService");
}
// simulation->writeToDisk(msg->payload, ss->hostname, location->getDiskOrNull());
std::cerr << "WRITING LAST CHNUNK TO THE DISK\n";
this->dst_opened_file->write(msg->payload);

#ifdef PAGE_CACHE_SIMULATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,23 @@ class SimpleStorageServiceLRUCachingCopyTestWMS : public wrench::ExecutionContro
auto file_60 = wrench::Simulation::addFile("file_60", 60);
auto file_70 = wrench::Simulation::addFile("file_70", 70);

std::cerr << "WRITING FILE 10\n";
ss1->writeFile(file_10);
std::cerr << "WRITING FILE 20\n";
ss1->writeFile(file_20);
std::cerr << "WRITING FILE 50\n";
ss1->writeFile(file_50);

std::cerr << "WRITING FILE 30\n";
ss2->writeFile(file_30);
std::cerr << "WRITING FILE 40\n";
ss2->writeFile(file_40);

// The LRU list: SS1: file_10, file_20, file_50
// SS2: file_30, file_40

// Copy file_50 SS1 -> SS2
std::cerr << "************************ DOING THE FILE COPY ******************* \n";
wrench::StorageService::copyFile(wrench::FileLocation::LOCATION(ss1, file_50), wrench::FileLocation::LOCATION(ss2, file_50));

// The LRU list: SS1: file_10, file_20, file_50
Expand Down Expand Up @@ -286,6 +292,11 @@ void SimpleStorageServiceCachingTest::do_SimpleLRUCachingCopy_test(double buffer
// Create and initialize a simulation
auto simulation = wrench::Simulation::createSimulation();

std::cerr << "************************************************\n";
std::cerr << "************ BUFFER SIZE: " << buffer_size << " *****************\n";
std::cerr << "************************************************\n";


int argc = 1;
char **argv = (char **) calloc(argc, sizeof(char *));
argv[0] = strdup("unit_test");
Expand Down

0 comments on commit a80708d

Please sign in to comment.