Commit 5ba5b9a4 authored by Steffen Lackner's avatar Steffen Lackner
Browse files

[code] change the message sent from the scheduler to be a json document itself...

[code] change the message sent from the scheduler to be a json document itself (defined in the workload)
parent de1cd4f1
......@@ -8,6 +8,8 @@
#include <vector>
#include <string>
#include <rapidjson/document.h>
#include <simgrid/msg.h>
#include "machine_range.hpp"
......@@ -245,7 +247,7 @@ struct ToJobMessage
struct FromJobMessage
{
JobIdentifier job_id; //!< The JobIdentifier
std::string message; //!< The message to send to the scheduler
rapidjson::Document message; //!< The message to send to the scheduler
};
/**
......
......@@ -299,12 +299,13 @@ int execute_profile(BatsimContext *context,
{
SchedulerSendProfileData * data = (SchedulerSendProfileData *) profile->data;
XBT_INFO("Sending message to the scheduler: %s", data->message.c_str());
XBT_INFO("Sending message to the scheduler");
context->proto_writer->append_from_job_message(job->id, data->message, MSG_get_clock());
FromJobMessage * message = new FromJobMessage;
message->job_id = job_id;
message->message = data->message;
message->message.CopyFrom(data->message, message->message.GetAllocator());
send_message("server", IPMessageType::FROM_JOB_MSG, (void*)message);
if (delay_job(0.005, remaining_time) == -1)
......
......@@ -439,7 +439,10 @@ Profile *Profile::from_json(const std::string & profile_name,
xbt_assert(json_desc.HasMember("msg"), "%s: profile '%s' has no 'msg' field",
error_prefix.c_str(), profile_name.c_str());
data->message = json_desc["msg"].GetString();
xbt_assert(json_desc["msg"].IsObject(), "%s: profile '%s' field 'msg' is no object",
error_prefix.c_str(), profile_name.c_str());
data->message.CopyFrom(json_desc["msg"], data->message.GetAllocator());
profile->data = data;
}
......
......@@ -160,7 +160,7 @@ struct MsgDataStagingProfileData
*/
struct SchedulerSendProfileData
{
std::string message; //!< The message being sent to the scheduler
rapidjson::Document message; //!< The message being sent to the scheduler
};
/**
......
......@@ -254,8 +254,8 @@ void JsonProtocolWriter::append_job_killed(const vector<string> & job_ids,
_events.PushBack(event, _alloc);
}
void JsonProtocolWriter::append_from_job_message(const std::string & job_id,
const std::string & message,
void JsonProtocolWriter::append_from_job_message(const string & job_id,
const Document & message,
double date)
{
/* {
......@@ -274,7 +274,7 @@ void JsonProtocolWriter::append_from_job_message(const std::string & job_id,
Value data(rapidjson::kObjectType);
data.AddMember("job_id",
Value().SetString(job_id.c_str(), _alloc), _alloc);
data.AddMember("msg", Value().SetString(message.c_str(), _alloc), _alloc);
data.AddMember("msg", Value().CopyFrom(message, _alloc), _alloc);
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
......
......@@ -128,7 +128,7 @@ public:
* @param[in] date The event date. Must be greater than or equal to the previous event.
*/
virtual void append_from_job_message(const std::string & job_id,
const std::string & message,
const rapidjson::Document & message,
double date) = 0;
/**
......@@ -258,7 +258,7 @@ public:
* @param[in] date The event date. Must be greater than or equal to the previous event.
*/
void append_from_job_message(const std::string & job_id,
const std::string & message,
const rapidjson::Document & message,
double date);
/**
......
......@@ -701,9 +701,8 @@ void server_on_from_job_msg(ServerData * data,
Job * job = data->context->workloads.job_at(message->job_id);
XBT_INFO("Send message to scheduler: Job %d (workload=%s) message=%s",
job->number, job->workload->name.c_str(),
message->message.c_str());
XBT_INFO("Send message to scheduler: Job %d (workload=%s)",
job->number, job->workload->name.c_str());
data->context->proto_writer->append_from_job_message(message->job_id.to_string(),
message->message,
......
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