Commit e6f136e5 authored by MERCIER Michael's avatar MERCIER Michael

[code] Add a forward profile on job kill option

parent dc9abe94
......@@ -5,20 +5,23 @@ default configuration:
```json
{
"redis": {
"enabled": false,
"hostname": "127.0.0.1",
"port": 6379,
"prefix": "default"
},
"job_submission": {
"forward_profiles": false,
"from_scheduler": {
"enabled": false,
"acknowledge": true
}
}
}
"redis": {
"enabled": false,
"hostname": "127.0.0.1",
"port": 6379,
"prefix": "default"
},
"job_submission": {
"forward_profiles": false,
"from_scheduler": {
"enabled": false,
"acknowledge": true
}
},
"job_kill": {
"forward_profiles": false
}
}
```
This configuration can be override using the ``--config-file`` option. Each
......
......@@ -79,6 +79,9 @@ string default_configuration = R"({
"enabled": false,
"acknowledge": true
}
},
"job_kill": {
"forward_profiles": false
}
})";
......@@ -835,6 +838,8 @@ void set_configuration(BatsimContext *context,
bool submission_sched_enabled = default_config_doc["job_submission"]["from_scheduler"]["enabled"].GetBool();
bool submission_sched_ack = default_config_doc["job_submission"]["from_scheduler"]["acknowledge"].GetBool();
bool kill_forward_profiles = default_config_doc["job_kill"]["forward_profiles"].GetBool();
// **********************************
// Let's parse the configuration file
// **********************************
......@@ -906,6 +911,19 @@ void set_configuration(BatsimContext *context,
}
}
}
if (main_object.HasMember("job_kill"))
{
const Value & job_kill_object = main_object["job_kill"];
xbt_assert(job_kill_object.IsObject(), "Invalid JSON configuration: ['job_kill'] should be an object.");
if (job_kill_object.HasMember("forward_profiles"))
{
const Value & forward_profiles_value = job_kill_object["forward_profiles"];
xbt_assert(forward_profiles_value.IsBool(), "Invalid JSON configuration: ['job_kill']['forward_profiles'] should be a boolean.");
kill_forward_profiles = forward_profiles_value.GetBool();
}
}
// *****************************************************************
// Let's override configuration values from main arguments if needed
......@@ -930,6 +948,7 @@ void set_configuration(BatsimContext *context,
context->submission_forward_profiles = submission_forward_profiles;
context->submission_sched_enabled = submission_sched_enabled;
context->submission_sched_ack = submission_sched_ack;
context->kill_forward_profiles = kill_forward_profiles;
context->platform_filename = main_args.platform_filename;
context->export_prefix = main_args.export_prefix;
......@@ -1039,4 +1058,18 @@ void set_configuration(BatsimContext *context,
{
from_sched_value.AddMember("acknowledge", Value().SetBool(submission_sched_ack), alloc);
}
// job_kill
auto mit_job_kill = context->config_file.FindMember("job_kill");
if (mit_job_kill == context->config_file.MemberEnd())
{
context->config_file.AddMember("job_kill", Value().SetObject(), alloc);
mit_job_kill = context->config_file.FindMember("job_kill");
}
// job_kill->forward_profiles
if (mit_job_kill->value.FindMember("forward_profiles") == mit_job_kill->value.MemberEnd())
{
mit_job_kill->value.AddMember("forward_profiles", Value().SetBool(kill_forward_profiles), alloc);
}
}
......@@ -52,10 +52,11 @@ struct BatsimContext
rapidjson::Document config_file; //!< The configuration file
bool redis_enabled; //!< Stores whether Redis should be used
bool submission_forward_profiles; //!< Stores whether the profile information of jobs should be sent to the scheduler
bool submission_forward_profiles; //!< Stores whether the profile information of submitted jobs should be sent to the scheduler
bool submission_sched_enabled; //!< Stores whether the scheduler will be able to send jobs along the simulation
bool submission_sched_finished = false; //!< Stores whether the scheduler has finished submitting jobs.
bool submission_sched_ack; //!< Stores whether Batsim will acknowledge dynamic job submission (emit JOB_SUBMITTED events)
bool kill_forward_profiles; //!< Stores whether the profile information of killed jobs should be sent to the scheduler
bool terminate_with_last_workflow; //!< If true, allows to ignore the jobs submitted after the last workflow termination
......
......@@ -264,22 +264,33 @@ void JsonProtocolWriter::append_job_completed(const string & job_id,
/**
* @brief Create task tree with progress in Json and add it to _alloc
*/
Value generate_task_tree(BatTask* task_tree, rapidjson::Document::AllocatorType & _alloc)
Value generate_task_tree(BatTask* task_tree, rapidjson::Document::AllocatorType & _alloc, bool forward_profiles)
{
Value task(rapidjson::kObjectType);
// add final task (leaf) progress
if (task_tree->ptask != nullptr || task_tree->delay_task_start != -1)
{
task.AddMember("profile", Value().SetString(task_tree->profile->name.c_str(), _alloc), _alloc);
task.AddMember("profile_name", Value().SetString(task_tree->profile->name.c_str(), _alloc), _alloc);
task.AddMember("progress", Value().SetDouble(task_tree->current_task_progress_ratio), _alloc);
if (forward_profiles)
{
// Add profile description
Document profile_description_doc;
const string & profile_json_description = task_tree->profile->json_description;
profile_description_doc.Parse(profile_json_description.c_str());
xbt_assert(!profile_description_doc.HasParseError());
task.AddMember("profile", Value().CopyFrom(profile_description_doc, _alloc), _alloc);
}
}
else
{
task.AddMember("profile", Value().SetString(task_tree->profile->name.c_str(), _alloc), _alloc);
task.AddMember("profile_name", Value().SetString(task_tree->profile->name.c_str(), _alloc), _alloc);
task.AddMember("current_task_index", Value().SetInt(task_tree->current_task_index), _alloc);
BatTask * btask = task_tree->sub_tasks[task_tree->current_task_index];
task.AddMember("current_task", generate_task_tree(btask, _alloc), _alloc);
task.AddMember("current_task", generate_task_tree(btask, _alloc, forward_profiles), _alloc);
}
return task;
}
......@@ -349,7 +360,7 @@ void JsonProtocolWriter::append_job_killed(const vector<string> & job_ids,
// compute task progress tree
if (job_progress.at(job_id) != nullptr) {
progress.AddMember(Value().SetString(job_id.c_str(), _alloc),
generate_task_tree(job_progress.at(job_id), _alloc), _alloc);
generate_task_tree(job_progress.at(job_id), _alloc, _context->kill_forward_profiles), _alloc);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment