Commit 3630ceea authored by Millian Poquet's avatar Millian Poquet
Browse files

[code] refactoring

parent 9aa37abb
......@@ -113,8 +113,8 @@ struct JobSubmittedMessage
struct JobSubmittedByDPMessage
{
JobIdentifier job_id; //!< The JobIdentifier of the new job
std::string job_description; //!< The job description string
std::string job_profile; //!< The profile of the job (can me empty if the job uses an existing profile)
std::string job_description; //!< The job description string (empty if redis is enabled)
std::string job_profile_description; //!< The profile of the job (empty if redis is enabled)
};
/**
......
......@@ -768,11 +768,11 @@ void JsonProtocolReader::handle_submit_job(int event_number,
if (data_object.HasMember("job"))
{
xbt_assert(!context->redis_enabled, "Invalid JSON message: in event %d (SUBMIT_JOB): 'job' object is given but redis seems disabled...", event_number);
const Value & job_object = data_object["job"];
xbt_assert(job_object.IsObject(), "Invalid JSON message: in event %d (SUBMIT_JOB): ['data']['job'] should be an object", event_number);
xbt_assert(!context->redis_enabled, "Invalid JSON message: in event %d (SUBMIT_JOB): 'job' object is given but redis seems disabled...", event_number);
StringBuffer buffer;
::Writer<rapidjson::StringBuffer> writer(buffer);
job_object.Accept(writer);
......@@ -784,11 +784,11 @@ void JsonProtocolReader::handle_submit_job(int event_number,
if (data_object.HasMember("profile"))
{
xbt_assert(!context->redis_enabled, "Invalid JSON message: in event %d (SUBMIT_JOB): 'profile' object is given but redis seems disabled...", event_number);
const Value & profile_object = data_object["profile"];
xbt_assert(profile_object.IsObject(), "Invalid JSON message: in event %d (SUBMIT_JOB): ['data']['profile'] should be an object", event_number);
xbt_assert(!context->redis_enabled, "Invalid JSON message: in event %d (SUBMIT_JOB): 'profile' object is given but redis seems disabled...", event_number);
StringBuffer buffer;
::Writer<rapidjson::StringBuffer> writer(buffer);
profile_object.Accept(writer);
......
......@@ -250,18 +250,23 @@ int server_process(int argc, char *argv[])
// Let's parse the user-submitted job
XBT_INFO("Parsing user-submitted job %s", message->job_id.to_string().c_str());
Job * job = Job::from_json(message->job_description, workload);
Job * job = Job::from_json(message->job_description, workload,
"Invalid JSON job submitted by the scheduler");
workload->jobs->add_job(job);
job->id = JobIdentifier(workload->name, job->number).to_string();
// Let's parse the profile if needed
if (!workload->profiles->exists(job->profile))
{
XBT_INFO("The profile of user-submitted job '%s' does not exist. Parsing the user-submitted profile '%s'",
job->profile.c_str(), message->job_id.to_string().c_str());
Profile * profile = Profile::from_json(job->profile, message->job_profile);
XBT_INFO("The profile of user-submitted job '%s' does not exist yet.",
job->profile.c_str());
Profile * profile = Profile::from_json(job->profile,
message->job_profile_description,
"Invalid JSON profile received from the scheduler");
workload->profiles->add_profile(job->profile, profile);
}
// TODO? check profile collisions otherwise
// Let's set the job state
job->state = JobState::JOB_STATE_SUBMITTED;
......
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