Commit ecde8b1a authored by Millian Poquet's avatar Millian Poquet
Browse files

[code] few fixes

parent 95c231e0
......@@ -124,6 +124,7 @@ void JsonProtocolWriter::append_simulation_begins(int nb_resources, double date)
xbt_assert(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
Value data(rapidjson::kObjectType);
data.AddMember("nb_resources", Value().SetInt(nb_resources), _alloc);
......@@ -146,6 +147,7 @@ void JsonProtocolWriter::append_simulation_ends(double date)
xbt_assert(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
......@@ -155,7 +157,7 @@ void JsonProtocolWriter::append_simulation_ends(double date)
_events.PushBack(event, _alloc);
}
void JsonProtocolWriter::append_job_submitted(const vector<string> & job_ids,
void JsonProtocolWriter::append_job_submitted(const string & job_id,
double date)
{
/* {
......@@ -168,17 +170,15 @@ void JsonProtocolWriter::append_job_submitted(const vector<string> & job_ids,
xbt_assert(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
Value data(rapidjson::kObjectType);
data.AddMember("job_id", Value().SetString(job_id.c_str(), _alloc), _alloc);
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
event.AddMember("type", Value().SetString("JOB_SUBMITTED"), _alloc);
Value jobs(rapidjson::kArrayType);
jobs.Reserve(job_ids.size(), _alloc);
for (const string & job_id : job_ids)
jobs.PushBack(Value().SetString(job_id.c_str(), _alloc), _alloc);
event.AddMember("data", Value().SetObject().AddMember("job_ids", jobs, _alloc), _alloc);
event.AddMember("data", data, _alloc);
_events.PushBack(event, _alloc);
}
......@@ -197,6 +197,7 @@ void JsonProtocolWriter::append_job_completed(const string & job_id,
xbt_assert(std::find(accepted_completion_statuses.begin(), accepted_completion_statuses.end(), job_status) != accepted_completion_statuses.end(),
"Unsupported job status '%s'!", job_status.c_str());
_last_date = date;
_is_empty = false;
Value data(rapidjson::kObjectType);
data.AddMember("job_id", Value().SetString(job_id.c_str(), _alloc), _alloc);
......@@ -221,6 +222,7 @@ void JsonProtocolWriter::append_job_killed(const vector<string> & job_ids,
xbt_assert(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
......@@ -248,6 +250,7 @@ void JsonProtocolWriter::append_resource_state_changed(const MachineRange & reso
xbt_assert(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
Value data(rapidjson::kObjectType);
data.AddMember("resources",
......@@ -273,6 +276,7 @@ void JsonProtocolWriter::append_query_reply_energy(double consumed_energy,
xbt_assert(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
......@@ -705,5 +709,5 @@ void JsonProtocolReader::dsend_message(double when,
MSG_process_sleep(when - current_time);
// Let's actually send the message
::dsend_message(destination_mailbox, type, data);
::send_message(destination_mailbox, type, data);
}
......@@ -141,10 +141,10 @@ public:
/**
* @brief Appends a JOB_SUBMITTED event.
* @param[in] job_ids The identifiers of the submitted jobs.
* @param[in] job_id The identifier of the submitted job.
* @param[in] date The event date. Must be greater than or equal to the previous event.
*/
virtual void append_job_submitted(const std::vector<std::string> & job_ids,
virtual void append_job_submitted(const std::string & job_id,
double date) = 0;
/**
......@@ -339,10 +339,10 @@ public:
/**
* @brief Appends a JOB_SUBMITTED event.
* @param[in] job_ids The identifiers of the submitted jobs.
* @param[in] job_id The identifier of the submitted job.
* @param[in] date The event date. Must be greater than or equal to the previous event.
*/
void append_job_submitted(const std::vector<std::string> & job_ids,
void append_job_submitted(const std::string & job_id,
double date);
/**
......
......@@ -208,7 +208,7 @@ int server_process(int argc, char *argv[])
XBT_INFO("Job %s SUBMITTED. %d jobs submitted so far",
message->job_id.to_string().c_str(), nb_submitted_jobs);
context->proto_writer->append_job_submitted({job->id}, MSG_get_clock());
context->proto_writer->append_job_submitted(job->id, MSG_get_clock());
} break; // end of case JOB_SUBMITTED
case IPMessageType::JOB_SUBMITTED_BY_DP:
......@@ -466,7 +466,6 @@ int server_process(int argc, char *argv[])
case IPMessageType::SCHED_READY:
{
sched_ready = true;
} break; // end of case SCHED_READY
case IPMessageType::SCHED_WAIT_ANSWER:
......
Supports Markdown
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