Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
batsim
batsim
Commits
fa2d0acb
Commit
fa2d0acb
authored
Apr 11, 2017
by
Millian Poquet
Browse files
[code+doc] SIM_BEGINS now sends batsim config
parent
0a9c6b01
Changes
6
Hide whitespace changes
Inline
Side-by-side
doc/proto_description.md
View file @
fa2d0acb
...
...
@@ -115,6 +115,11 @@ BATSIM ---> DECISION
Sent at the beginning of the simulation. Once it has been sent,
and if redis is enabled, meta-information can be read from Redis.
Batsim configuration is sent through the
``config``
object (in
``data``
).
Any custom information can be added into the
[
Batsim configuration
](
./configuration.md
)
, which gives a generic way to give
metainformation from Batsim to any scheduler at runtime.
-
**data**
: the number of resources
-
**example**
:
```
json
...
...
@@ -122,7 +127,8 @@ and if redis is enabled, meta-information can be read from Redis.
"timestamp"
:
0.0
,
"type"
:
"SIMULATION_BEGINS"
,
"data"
:
{
"nb_resources"
:
60
"nb_resources"
:
60
,
"config"
:{}
}
}
```
...
...
@@ -145,7 +151,7 @@ Sent once all jobs have been submitted and have completed.
Some jobs have been submitted within Batsim. It is sent whenever a job
coming from Batsim inputs (workloads and workflows) are submitted. It is
also sent as a reply to a
```SUBMIT_JOB```
message if and only if an
acknowledgement has been requested. Without Redis enabled the job
acknowledgement has been requested. Without Redis enabled the job
description and optionnaly the profile are also transmitted.
-
**data**
: list of job id
...
...
src/batsim.cpp
View file @
fa2d0acb
...
...
@@ -735,9 +735,58 @@ void set_configuration(BatsimContext *context,
// Let's write the values into the document to make sure they are all present
context
->
redis_enabled
=
redis_enabled
;
context
->
submission_forward_profiles
=
submission_forward_profiles
;
context
->
submission_sched_enabled
=
submission_sched_enabled
;
context
->
submission_sched_ack
=
submission_sched_ack
;
// *******************************************************************************
// Let's write the output config file (the one that will be sent to the scheduler)
// *******************************************************************************
auto
&
alloc
=
context
->
config_file
.
GetAllocator
();
// Let's retrieve all data specified in the input config file (to let the user give custom info to the scheduler)
context
->
config_file
.
CopyFrom
(
main_args
.
config_file
,
alloc
);
// Let's make sure all used data is written too.
// redis
auto
mit_redis
=
context
->
config_file
.
FindMember
(
"redis"
);
if
(
mit_redis
==
context
->
config_file
.
MemberEnd
())
{
context
->
config_file
.
AddMember
(
"redis"
,
Value
().
SetObject
(),
alloc
);
mit_redis
=
context
->
config_file
.
FindMember
(
"redis"
);
}
// redis->enabled
if
(
mit_redis
->
value
.
FindMember
(
"enabled"
)
==
mit_redis
->
value
.
MemberEnd
())
mit_redis
->
value
.
AddMember
(
"enabled"
,
Value
().
SetBool
(
redis_enabled
),
alloc
);
// job_submission
auto
mit_job_submission
=
context
->
config_file
.
FindMember
(
"job_submission"
);
if
(
mit_job_submission
==
context
->
config_file
.
MemberEnd
())
{
context
->
config_file
.
AddMember
(
"job_submission"
,
Value
().
SetObject
(),
alloc
);
mit_job_submission
=
context
->
config_file
.
FindMember
(
"job_submission"
);
}
// job_submission->forward_profiles
if
(
mit_job_submission
->
value
.
FindMember
(
"forward_profiles"
)
==
mit_job_submission
->
value
.
MemberEnd
())
mit_job_submission
->
value
.
AddMember
(
"forward_profiles"
,
Value
().
SetBool
(
submission_forward_profiles
),
alloc
);
// job_submission->from_scheduler
auto
mit_job_submission_from_sched
=
mit_job_submission
->
value
.
FindMember
(
"from_scheduler"
);
if
(
mit_job_submission_from_sched
==
mit_job_submission
->
value
.
MemberEnd
())
{
mit_job_submission
->
value
.
AddMember
(
"from_scheduler"
,
Value
().
SetObject
(),
alloc
);
mit_job_submission_from_sched
=
mit_job_submission
->
value
.
FindMember
(
"from_scheduler"
);
}
Value
&
from_sched_value
=
mit_job_submission_from_sched
->
value
;
// job_submission_from_scheduler->enabled
if
(
from_sched_value
.
FindMember
(
"enabled"
)
==
from_sched_value
.
MemberEnd
())
from_sched_value
.
AddMember
(
"enabled"
,
Value
().
SetBool
(
submission_sched_enabled
),
alloc
);
// job_submission_from_scheduler->acknowledge
if
(
from_sched_value
.
FindMember
(
"acknowledge"
)
==
from_sched_value
.
MemberEnd
())
from_sched_value
.
AddMember
(
"acknowledge"
,
Value
().
SetBool
(
submission_sched_ack
),
alloc
);
}
src/context.hpp
View file @
fa2d0acb
...
...
@@ -10,6 +10,8 @@
#include <zmq.hpp>
#include <rapidjson/document.h>
#include "exact_numbers.hpp"
#include "export.hpp"
#include "jobs.hpp"
...
...
@@ -48,6 +50,7 @@ struct BatsimContext
RedisStorage
storage
;
//!< The RedisStorage
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_sched_enabled
;
//!< Stores whether the scheduler will be able to send jobs along the simulation
...
...
src/protocol.cpp
View file @
fa2d0acb
...
...
@@ -113,7 +113,9 @@ void JsonProtocolWriter::append_query_request(void *anything,
void
JsonProtocolWriter
::
append_simulation_begins
(
int
nb_resources
,
double
date
)
void
JsonProtocolWriter
::
append_simulation_begins
(
int
nb_resources
,
const
Document
&
configuration
,
double
date
)
{
/* {
"timestamp": 0.0,
...
...
@@ -125,8 +127,12 @@ void JsonProtocolWriter::append_simulation_begins(int nb_resources, double date)
_last_date
=
date
;
_is_empty
=
false
;
Value
config
(
rapidjson
::
kObjectType
);
config
.
CopyFrom
(
configuration
,
_alloc
);
Value
data
(
rapidjson
::
kObjectType
);
data
.
AddMember
(
"nb_resources"
,
Value
().
SetInt
(
nb_resources
),
_alloc
);
data
.
AddMember
(
"config"
,
config
,
_alloc
);
Value
event
(
rapidjson
::
kObjectType
);
event
.
AddMember
(
"timestamp"
,
Value
().
SetDouble
(
date
),
_alloc
);
...
...
@@ -323,9 +329,9 @@ bool test_json_writer()
printf
(
"NOP content:
\n
%s
\n
"
,
proto_writer
->
generate_current_message
(
42
).
c_str
());
proto_writer
->
clear
();
proto_writer
->
append_simulation_begins
(
4
,
10
);
printf
(
"SIM_BEGINS content:
\n
%s
\n
"
,
proto_writer
->
generate_current_message
(
42
).
c_str
());
proto_writer
->
clear
();
//
proto_writer->append_simulation_begins(4, 10);
//
printf("SIM_BEGINS content:\n%s\n", proto_writer->generate_current_message(42).c_str());
//
proto_writer->clear();
proto_writer
->
append_simulation_ends
(
10
);
printf
(
"SIM_ENDS content:
\n
%s
\n
"
,
proto_writer
->
generate_current_message
(
42
).
c_str
());
...
...
src/protocol.hpp
View file @
fa2d0acb
...
...
@@ -171,9 +171,12 @@ public:
/**
* @brief Appends a SIMULATION_BEGINS event.
* @param[in] nb_resources The number of simulated resources
* @param[in] configuration The simulation configuration
* @param[in] date The event date. Must be greater than or equal to the previous event.
*/
virtual
void
append_simulation_begins
(
int
nb_resources
,
double
date
)
=
0
;
virtual
void
append_simulation_begins
(
int
nb_resources
,
const
rapidjson
::
Document
&
configuration
,
double
date
)
=
0
;
/**
* @brief Appends a SIMULATION_ENDS event.
...
...
@@ -367,11 +370,14 @@ public:
// Messages from Batsim to the Scheduler
/**
* @brief Appends a SIMULATION_
START
S event.
* @brief Appends a SIMULATION_
BEGIN
S event.
* @param[in] nb_resources The number of simulated resources
* @param[in] configuration The simulation configuration
* @param[in] date The event date. Must be greater than or equal to the previous event.
*/
void
append_simulation_begins
(
int
nb_resources
,
double
date
);
void
append_simulation_begins
(
int
nb_resources
,
const
rapidjson
::
Document
&
configuration
,
double
date
);
/**
* @brief Appends a SIMULATION_ENDS event.
...
...
src/server.cpp
View file @
fa2d0acb
...
...
@@ -58,7 +58,7 @@ int server_process(int argc, char *argv[])
map
<
std
::
pair
<
int
,
double
>
,
Submitter
*>
origin_of_wait_queries
;
// Let's tell the Decision process that the simulation is about to begin (and that some data can be read from the data storage)
context
->
proto_writer
->
append_simulation_begins
(
context
->
machines
.
nb_machines
(),
MSG_get_clock
());
context
->
proto_writer
->
append_simulation_begins
(
context
->
machines
.
nb_machines
(),
context
->
config_file
,
MSG_get_clock
());
RequestReplyProcessArguments
*
req_rep_args
=
new
RequestReplyProcessArguments
;
req_rep_args
->
context
=
context
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment