Skip to content

Commit

Permalink
Changed the Workflow::getInputFiles() and Simulation::stageFiles()
Browse files Browse the repository at this point in the history
methods to return/take maps of files (indexed by id) rather than
sets.
  • Loading branch information
henricasanova committed Feb 22, 2018
1 parent 851d1af commit 06a6766
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 75 deletions.
2 changes: 1 addition & 1 deletion examples/simple-wms/SimpleWMSBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int main(int argc, char **argv) {
* These files are then staged on the storage service.
*/
std::cerr << "Staging input files..." << std::endl;
std::set<wrench::WorkflowFile *> input_files = workflow.getInputFiles();
std::map<std::string, wrench::WorkflowFile *> input_files = workflow.getInputFiles();
try {
simulation.stageFiles(input_files, storage_service);
} catch (std::runtime_error &e) {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-wms/SimpleWMSCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ int main(int argc, char **argv) {
* These files are then staged on the storage service.
*/
std::cerr << "Staging input files..." << std::endl;
std::set<wrench::WorkflowFile *> input_files = workflow.getInputFiles();
std::map<std::string, wrench::WorkflowFile *> input_files = workflow.getInputFiles();
try {
simulation.stageFiles(input_files, storage_service);
} catch (std::runtime_error &e) {
Expand Down
2 changes: 1 addition & 1 deletion include/wrench/simulation/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace wrench {

void stageFile(WorkflowFile *file, StorageService *storage_service);

void stageFiles(std::set<WorkflowFile *> files, StorageService *storage_service);
void stageFiles(std::map<std::string, WorkflowFile *> files, StorageService *storage_service);

/** @brief The simulation post-mortem output */
SimulationOutput output;
Expand Down
2 changes: 1 addition & 1 deletion include/wrench/workflow/Workflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace wrench {

void exportToEPS(std::string);

std::set<WorkflowFile *>getInputFiles();
std::map<std::string, WorkflowFile *>getInputFiles();

/***********************/
/** \cond DEVELOPER */
Expand Down
10 changes: 5 additions & 5 deletions src/wrench/simulation/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ namespace wrench {

// Check that each input file is staged somewhere
for (auto f : wms->workflow->getInputFiles()) {
if (this->file_registry_service->entries.find(f) == this->file_registry_service->entries.end()) {
if (this->file_registry_service->entries.find(f.second) == this->file_registry_service->entries.end()) {
throw std::runtime_error(
"Workflow input file " + f->getId() + " is not staged on any storage service!");
"Workflow input file " + f.second->getId() + " is not staged on any storage service!");
}
}
}
Expand Down Expand Up @@ -468,13 +468,13 @@ namespace wrench {
/**
* @brief Stage a set of a file copies on a storage service
*
* @param files: a set of files to stage on a storage service
* @param files: a map of files (indexed by file ids) to stage on a storage service
* @param storage_service: the storage service
*
* @throw std::runtime_error
* @throw std::invalid_argument
*/
void Simulation::stageFiles(std::set<WorkflowFile *> files, StorageService *storage_service) {
void Simulation::stageFiles(std::map<std::string, WorkflowFile *> files, StorageService *storage_service) {

if (storage_service == nullptr) {
throw std::invalid_argument("Simulation::stageFiles(): Invalid arguments");
Expand All @@ -488,7 +488,7 @@ namespace wrench {

try {
for (auto f : files) {
this->stageFile(f, storage_service);
this->stageFile(f.second, storage_service);
}
} catch (std::runtime_error &e) {
throw;
Expand Down
10 changes: 5 additions & 5 deletions src/wrench/workflow/Workflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,16 +569,16 @@ namespace wrench {
}

/**
* @brief Retrieve the set of input files for a workflow (i.e., those files
* @brief Retrieve a map (indexed by file id) of input files for a workflow (i.e., those files
* that are input to some tasks but output from none)
*
* @return a std::set of files
* @return a std::map of files
*/
std::set<WorkflowFile *> Workflow::getInputFiles() {
std::set<WorkflowFile *> input_files;
std::map<std::string, WorkflowFile *> Workflow::getInputFiles() {
std::map<std::string, WorkflowFile *> input_files;
for (auto const &x : this->files) {
if ((x.second->output_of == nullptr) && (x.second->input_of.size() > 0)) {
input_files.insert(x.second.get());
input_files.insert({x.first, x.second.get()});
}
}
return input_files;
Expand Down
34 changes: 17 additions & 17 deletions test/simulation/BatchServiceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void BatchServiceTest::do_StandardJobTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));

// Running a "run a single task" simulation
// Note that in these tests the WMS creates workflow tasks, which a user would
Expand Down Expand Up @@ -386,7 +386,7 @@ void BatchServiceTest::do_PilotJobTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -588,7 +588,7 @@ void BatchServiceTest::do_StandardPlusPilotJobTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -731,7 +731,7 @@ void BatchServiceTest::do_InsufficientCoresTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -867,7 +867,7 @@ void BatchServiceTest::do_noArgumentsJobSubmissionTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -1020,7 +1020,7 @@ void BatchServiceTest::do_StandardJobTimeOutTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -1171,7 +1171,7 @@ void BatchServiceTest::do_PilotJobTimeOutTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -1393,9 +1393,9 @@ void BatchServiceTest::do_BestFitTaskTest_test() {
wrench::WorkflowFile *output_file_2 = this->workflow->addFile("output_file_2", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFiles({input_file_1}, storage_service1));
EXPECT_NO_THROW(simulation->stageFiles({input_file_2}, storage_service1));
EXPECT_NO_THROW(simulation->stageFiles({{input_file->getId(), input_file},
{input_file_1->getId(), input_file_1},
{input_file_2->getId(), input_file_2}}, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -1586,7 +1586,7 @@ void BatchServiceTest::do_StandardJobInsidePilotJobTimeOutTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -1779,7 +1779,7 @@ void BatchServiceTest::do_StandardJobInsidePilotJobSucessTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -1955,7 +1955,7 @@ void BatchServiceTest::do_InsufficientCoresInsidePilotJobTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -2112,7 +2112,7 @@ void BatchServiceTest::do_MultipleStandardTaskTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -2280,7 +2280,7 @@ void BatchServiceTest::do_DifferentBatchAlgorithmsSubmissionTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));

// Running a "run a single task" simulation
// Note that in these tests the WMS creates workflow tasks, which a user would
Expand Down Expand Up @@ -2446,7 +2446,7 @@ void BatchServiceTest::do_BatchFakeJobSubmissionTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down Expand Up @@ -2627,7 +2627,7 @@ void BatchServiceTest::do_BatchTraceFileJobSubmissionTest_test() {
wrench::WorkflowFile *output_file = this->workflow->addFile("output_file", 20000.0);

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service1));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service1));


// Running a "run a single task" simulation
Expand Down
6 changes: 3 additions & 3 deletions test/simulation/CloudServiceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void CloudServiceTest::do_StandardJobTaskTest_test() {
std::unique_ptr<wrench::FileRegistryService>(new wrench::FileRegistryService(hostname))));

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -332,7 +332,7 @@ void CloudServiceTest::do_PilotJobTaskTest_test() {
std::unique_ptr<wrench::FileRegistryService>(new wrench::FileRegistryService(hostname))));

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -453,7 +453,7 @@ void CloudServiceTest::do_NumCoresTest_test() {
std::unique_ptr<wrench::FileRegistryService>(new wrench::FileRegistryService(hostname))));

// Staging the input_file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void MultihostMulticoreComputeServiceTestPilotJobs::do_UnsupportedPilotJobs_test


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFiles({{input_file->getId(), input_file}}, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -370,7 +370,7 @@ void MultihostMulticoreComputeServiceTestPilotJobs::do_OnePilotJobNoTimeoutWaitF
simulation->setFileRegistryService(std::move(file_registry_service));

// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFiles({{input_file->getId(), input_file}}, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -531,7 +531,7 @@ void MultihostMulticoreComputeServiceTestPilotJobs::do_OnePilotJobNoTimeoutShutd


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFiles({{input_file->getId(), input_file}}, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -651,7 +651,7 @@ void MultihostMulticoreComputeServiceTestPilotJobs::do_NonSubmittedPilotJobTermi


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFiles({{input_file->getId(), input_file}}, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -815,7 +815,7 @@ void MultihostMulticoreComputeServiceTestPilotJobs::do_IdlePilotJobTermination_t


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFiles({{input_file->getId(), input_file}}, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -986,7 +986,7 @@ void MultihostMulticoreComputeServiceTestPilotJobs::do_NonIdlePilotJobTerminatio


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_UnsupportedStandardJob


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -352,7 +352,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_TwoSingleCoreTasks_tes


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFiles({{input_file->getId(), input_file}}, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -486,7 +486,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_TwoDualCoreTasksCase1_


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFiles({{input_file->getId(), input_file}}, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -625,7 +625,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_TwoDualCoreTasksCase2_


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -746,7 +746,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_JobTermination_test()


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -884,7 +884,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_NonSubmittedJobTermina


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -1032,7 +1032,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_CompletedJobTerminatio


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -1180,7 +1180,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_ShutdownComputeService


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down Expand Up @@ -1333,7 +1333,7 @@ void MultihostMulticoreComputeServiceTestStandardJobs::do_ShutdownStorageService


// Staging the input file on the storage service
EXPECT_NO_THROW(simulation->stageFiles({input_file}, storage_service));
EXPECT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Running a "run a single task" simulation
EXPECT_NO_THROW(simulation->launch());
Expand Down

0 comments on commit 06a6766

Please sign in to comment.