Skip to content
Snippets Groups Projects
Commit 5d9cf4ef authored by Millian Poquet's avatar Millian Poquet
Browse files

[code] update for batsim-3.0

- config from SIMULATION_BEGINS has changed
- SUBMIT_{PROFILE,JOB} have been renamed
parent 39a30d83
Branches
No related tags found
No related merge requests found
......@@ -69,10 +69,10 @@ void Submitter::on_simulation_start(double date, const rapidjson::Value & batsim
available_machines.insert(IntervalSet::ClosedInterval(0, _nb_machines - 1));
PPK_ASSERT_ERROR(available_machines.size() == (unsigned int) _nb_machines);
PPK_ASSERT_ERROR(batsim_config["job_submission"]["from_scheduler"]["enabled"].GetBool(),
"This algorithm only works if dynamic job submissions are enabled!");
dyn_submit_ack = batsim_config["job_submission"]["from_scheduler"]["acknowledge"].GetBool();
redis_enabled = batsim_config["redis"]["enabled"].GetBool();
PPK_ASSERT_ERROR(batsim_config["dynamic-jobs-enabled"].GetBool(),
"This algorithm only works if dynamic job are enabled!");
dyn_submit_ack = batsim_config["dynamic-jobs-acknowledged"].GetBool();
redis_enabled = batsim_config["redis-enabled"].GetBool();
}
void Submitter::on_simulation_end(double date)
......
......@@ -39,8 +39,8 @@ private:
int nb_submitted_jobs = 0; //!< The number of jobs submitted from this algorithm
int nb_jobs_to_submit = 10; //!< The number of jobs to submit
bool increase_jobs_duration = true; //!< Whether the duration of the submitted jobs increases or not. If false, the same profile will be used by all the submitted jobs.
bool send_profile_if_already_sent = true; //!< Whether already transmitted profiles should be sent again to Batsim or not.
bool send_profiles_in_separate_event = false; //!< Whether profiles should be sent in a separate message or not
bool send_profile_if_already_sent = false; //!< Whether already transmitted profiles should be sent again to Batsim or not.
bool send_profiles_in_separate_event = true; //!< Whether profiles should be sent in a separate message or not
bool set_job_metadata = false; //! If set to true, metadata will be associated to jobs when they are submitted.
bool dyn_submit_ack;
......
......@@ -56,10 +56,10 @@ void SchedulingDecision::add_submit_job(const string & workload_name,
_redis->set(job_key, job_json_description);
_redis->set(profile_key, profile_json_description);
_proto_writer->append_submit_job(complete_job_id, date, "", "", send_profile);
_proto_writer->append_register_job(complete_job_id, date, "", "", send_profile);
}
else
_proto_writer->append_submit_job(complete_job_id, date,
_proto_writer->append_register_job(complete_job_id, date,
job_json_description,
profile_json_description,
send_profile);
......@@ -70,7 +70,7 @@ void SchedulingDecision::add_submit_profile(const string &workload_name,
const string &profile_json_description,
double date)
{
_proto_writer->append_submit_profile(workload_name,
_proto_writer->append_register_profile(workload_name,
profile_name,
profile_json_description,
date);
......
......@@ -390,13 +390,13 @@ void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision & d,
{
nb_resources = event_data["nb_resources"].GetInt();
}
redis_enabled = event_data["config"]["redis"]["enabled"].GetBool();
redis_enabled = event_data["config"]["redis-enabled"].GetBool();
if (redis_enabled)
{
string redis_hostname = event_data["config"]["redis"]["hostname"].GetString();
int redis_port = event_data["config"]["redis"]["port"].GetInt();
string redis_prefix = event_data["config"]["redis"]["prefix"].GetString();
string redis_hostname = event_data["config"]["redis-hostname"].GetString();
int redis_port = event_data["config"]["redis-port"].GetInt();
string redis_prefix = event_data["config"]["redis-prefix"].GetString();
redis.connect_to_server(redis_hostname, redis_port, nullptr);
redis.set_instance_key_prefix(redis_prefix);
......
......@@ -79,7 +79,7 @@ void JsonProtocolWriter::append_answer_estimate_waiting_time(const string &job_i
_events.PushBack(event, _alloc);
}
void JsonProtocolWriter::append_submit_job(const string &job_id,
void JsonProtocolWriter::append_register_job(const string &job_id,
double date,
const string &job_description,
const string &profile_description,
......@@ -87,14 +87,14 @@ void JsonProtocolWriter::append_submit_job(const string &job_id,
{
/* Without redis: {
"timestamp": 10.0,
"type": "SUBMIT_JOB",
"type": "REGISTER_JOB",
"data": {
"job_id": "w12!45",
}
}
With redis: {
"timestamp": 10.0,
"type": "SUBMIT_JOB",
"type": "REGISTER_JOB",
"data": {
"job_id": "dyn!my_new_job",
"job":{
......@@ -141,20 +141,20 @@ void JsonProtocolWriter::append_submit_job(const string &job_id,
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
event.AddMember("type", Value().SetString("SUBMIT_JOB"), _alloc);
event.AddMember("type", Value().SetString("REGISTER_JOB"), _alloc);
event.AddMember("data", data, _alloc);
_events.PushBack(event, _alloc);
}
void JsonProtocolWriter::append_submit_profile(const string &workload_name,
void JsonProtocolWriter::append_register_profile(const string &workload_name,
const string &profile_name,
const string &profile_description,
double date)
{
/* {
"timestamp": 10.0,
"type": "SUBMIT_PROFILE",
"type": "REGISTER_PROFILE",
"data": {
"workload_name": "dyn_wl1",
"profile_name": "delay_10s",
......@@ -185,7 +185,7 @@ void JsonProtocolWriter::append_submit_profile(const string &workload_name,
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
event.AddMember("type", Value().SetString("SUBMIT_PROFILE"), _alloc);
event.AddMember("type", Value().SetString("REGISTER_PROFILE"), _alloc);
event.AddMember("data", data, _alloc);
_events.PushBack(event, _alloc);
......@@ -374,7 +374,7 @@ void JsonProtocolWriter::append_scheduler_finished_submitting_jobs(double date)
/* {
"timestamp": 42.0,
"type": "NOTIFY",
"data": { "type": "submission_finished" }
"data": { "type": "registration_finished" }
} */
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
......@@ -382,7 +382,7 @@ void JsonProtocolWriter::append_scheduler_finished_submitting_jobs(double date)
_is_empty = false;
Value data(rapidjson::kObjectType);
data.AddMember("type", Value().SetString("submission_finished", _alloc), _alloc);
data.AddMember("type", Value().SetString("registration_finished", _alloc), _alloc);
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
......
......@@ -40,7 +40,7 @@ public:
// Messages from the Scheduler to Batsim
/**
* @brief Appends a SUBMIT_JOB event.
* @brief Appends a REGISTER_JOB event.
* @details The job_description and profile_descriptions are either both given or both empty.
* If they are given, the job and profile information is sent within the protocol.
* Otherwise, it is sent by another channel (probably redis).
......@@ -50,13 +50,13 @@ public:
* @param[in] job_description The job description string. Can be empty.
* @param[in] profile_description The profile description string. Can be empty.
*/
virtual void append_submit_job(const std::string & job_id,
virtual void append_register_job(const std::string & job_id,
double date,
const std::string & job_description = "",
const std::string & profile_description = "",
bool send_profile = true) = 0;
virtual void append_submit_profile(const std::string & workload_name,
virtual void append_register_profile(const std::string & workload_name,
const std::string & profile_name,
const std::string & profile_description,
double date) = 0;
......@@ -193,7 +193,7 @@ public:
// Messages from the Scheduler to Batsim
/**
* @brief Appends a SUBMIT_JOB event.
* @brief Appends a REGISTER_JOB event.
* @details The job_description and profile_descriptions are either both given or both empty.
* If they are given, the job and profile information is sent within the protocol.
* Otherwise, it is sent by another channel (probably redis).
......@@ -203,13 +203,13 @@ public:
* @param[in] job_description The job description string. Can be empty.
* @param[in] profile_description The profile description string. Can be empty.
*/
void append_submit_job(const std::string & job_id,
void append_register_job(const std::string & job_id,
double date,
const std::string & job_description = "",
const std::string & profile_description = "",
bool send_profile = true);
void append_submit_profile(const std::string & workload_name,
void append_register_profile(const std::string & workload_name,
const std::string & profile_name,
const std::string & profile_description,
double date);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment