Skip to content

Commit

Permalink
Added a Worfklow::getFiles() method
Browse files Browse the repository at this point in the history
Make Simulation::launch() less strict (e.g., when the workflow has no
files, it's ok to not have a storage service)
  • Loading branch information
henricasanova committed Oct 10, 2017
1 parent 10adba9 commit 7d8bee1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 48 deletions.
3 changes: 3 additions & 0 deletions include/wrench/workflow/Workflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ namespace wrench {

std::vector<WorkflowTask *> getTasks();

std::vector<WorkflowFile *> getFiles();


std::vector<WorkflowTask *> getTaskParents(const WorkflowTask *task);

std::vector<WorkflowTask *> getTaskChildren(const WorkflowTask *task);
Expand Down
20 changes: 11 additions & 9 deletions src/wrench/simulation/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,18 @@ namespace wrench {
"Simulation::launch(): At least one ComputeService should have been instantiated add passed to Simulation.add()");
}

// Check that at least one StorageService is running
bool one_storage_service_running = false;
for (auto it = this->storage_services.begin(); it != this->storage_services.end(); it++) {
if ((*it)->state == Service::UP) {
one_storage_service_running = true;
// Check that at least one StorageService is running (only needed if there are files in the workflow)
if (this->wms->workflow->getFiles().size() > 0) {
bool one_storage_service_running = false;
for (auto it = this->storage_services.begin(); it != this->storage_services.end(); it++) {
if ((*it)->state == Service::UP) {
one_storage_service_running = true;
}
}
if (!one_storage_service_running) {
throw std::runtime_error(
"Simulation::launch(): At least one StorageService should have been instantiated add passed to Simulation.add()");
}
}
if (!one_storage_service_running) {
throw std::runtime_error(
"Simulation::launch(): At least one StorageService should have been instantiated add passed to Simulation.add()");
}

// Check that a FileRegistryService is running if needed
Expand Down
15 changes: 14 additions & 1 deletion src/wrench/workflow/Workflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,25 @@ namespace wrench {
*/
std::vector<WorkflowTask *> Workflow::getTasks() {
std::vector<WorkflowTask *> all_tasks;
for (auto &it : tasks) {
for (auto &it : this->tasks) {
all_tasks.push_back(it.second.get());
}
return all_tasks;
};

/**
* @brief Get a list of all files in the workflow
*
* @return a vector of workflow files
*/
std::vector<WorkflowFile *> Workflow::getFiles() {
std::vector<WorkflowFile *> all_files;
for (auto &it : this->files) {
all_files.push_back(it.second.get());
}
return all_files;
};

/**
* @brief Get list of children for a task
*
Expand Down
55 changes: 17 additions & 38 deletions test/simulation/MultihostMulticoreComputeServiceSchedulingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Log category for test");
class MultihostMulticoreComputeServiceTestScheduling : public ::testing::Test {

public:
wrench::WorkflowFile *input_file;
wrench::StorageService *storage_service1 = nullptr;
// wrench::WorkflowFile *output_file1;
// wrench::WorkflowFile *output_file2;
// wrench::WorkflowFile *output_file3;
// wrench::WorkflowFile *output_file4;
// wrench::WorkflowTask *task1;
// wrench::WorkflowTask *task2;
// wrench::WorkflowTask *task3;
// wrench::WorkflowTask *task4;

wrench::ComputeService *compute_service = nullptr;

void do_Noop_test();
Expand All @@ -45,19 +34,6 @@ class MultihostMulticoreComputeServiceTestScheduling : public ::testing::Test {
// Create the simplest workflow
workflow = new wrench::Workflow();

// Create the files
// input_file = workflow->addFile("input_file", 10.0);
// output_file1 = workflow->addFile("output_file1", 10.0);

// // Create one task
// task1 = workflow->addTask("task_1_10s_1core", 10.0, 1, 1, 1.0);

// Add file-task dependencies
// task1->addInputFile(input_file);
//
// task1->addOutputFile(output_file1);


// Create a two-host quad-core platform file
std::string xml = "<?xml version='1.0'?>"
"<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">"
Expand Down Expand Up @@ -100,16 +76,24 @@ class XNoopTestWMS : public wrench::WMS {

int main() {

// Create a job manager
std::unique_ptr<wrench::JobManager> job_manager =
std::unique_ptr<wrench::JobManager>(new wrench::JobManager(this->workflow));

// // Create a job manager
// std::unique_ptr<wrench::JobManager> job_manager =
// std::unique_ptr<wrench::JobManager>(new wrench::JobManager(this->workflow));
//
// // Create a data movement manager
// std::unique_ptr<wrench::DataMovementManager> data_movement_manager =
// std::unique_ptr<wrench::DataMovementManager>(new wrench::DataMovementManager(this->workflow));
//
// // Terminate
// Create a job with 3
wrench::WorkflowTask *t1 = this->workflow->addTask("task1", 60, 2, 4, 1.0);
wrench::WorkflowTask *t2 = this->workflow->addTask("task2", 60, 2, 4, 1.0);
wrench::WorkflowTask *t3 = this->workflow->addTask("task3", 60, 4, 4, 1.0);

std::vector<wrench::WorkflowTask *> tasks;

tasks.push_back(t1);
tasks.push_back(t2);
tasks.push_back(t3);
job_manager->createStandardJob(tasks, {}, {}, {}, {});


// Terminate
this->simulation->shutdownAllComputeServices();
this->simulation->shutdownAllStorageServices();
return 0;
Expand Down Expand Up @@ -151,11 +135,6 @@ void MultihostMulticoreComputeServiceTestScheduling::do_Noop_test() {
nullptr,
{}))));

// Create a Storage Service
EXPECT_NO_THROW(storage_service1 = simulation->add(
std::unique_ptr<wrench::SimpleStorageService>(
new wrench::SimpleStorageService(hostname, 10000000000000.0))));

EXPECT_NO_THROW(simulation->launch());

delete simulation;
Expand Down

0 comments on commit 7d8bee1

Please sign in to comment.