Commit 2ddf263b authored by Steffen Lackner's avatar Steffen Lackner
Browse files

[code] send the hpst and lcst information to the scheduler

parent 4527b01d
......@@ -341,6 +341,11 @@ const Machine *Machines::pfs_machine() const
return _pfs_machine;
}
bool Machines::has_pfs_machine() const
{
return _pfs_machine != nullptr;
}
const Machine *Machines::hpst_machine() const
{
xbt_assert(_hpst_machine != nullptr,
......@@ -348,7 +353,10 @@ const Machine *Machines::hpst_machine() const
return _hpst_machine;
}
bool Machines::has_hpst_machine() const
{
return _hpst_machine != nullptr;
}
long double Machines::total_consumed_energy(const BatsimContext *context) const
{
......
......@@ -222,6 +222,12 @@ public:
*/
const Machine * pfs_machine() const;
/**
* @brief Returns whether or not a pfs host is registered in the system.
* @return Whether or not a pfs host is present
*/
bool has_pfs_machine() const;
/**
* @brief Returns a const pointer to the Parallel File System host machine
* for the high-performance storage tier.
......@@ -229,6 +235,12 @@ public:
*/
const Machine * hpst_machine() const;
/**
* @brief Returns whether or not a hpst host is registered in the system.
* @return Whether or not a hpst host is present
*/
bool has_hpst_machine() const;
/**
* @brief Computes and returns the total consumed energy of all the computing machines
* @param[in] context The Batsim context
......
......@@ -69,14 +69,18 @@ void JsonProtocolWriter::append_simulation_begins(Machines & machines,
resources.Reserve(machines.nb_machines(), _alloc);
for (const Machine * machine : machines.machines())
{
Value machine_doc(rapidjson::kObjectType);
machine_doc.AddMember("id", Value().SetInt(machine->id), _alloc);
machine_doc.AddMember("name", Value().SetString(machine->name.c_str(), _alloc), _alloc);
machine_doc.AddMember("state", Value().SetString(machine_state_to_string(machine->state).c_str(), _alloc), _alloc);
resources.PushBack(machine_doc, _alloc);
resources.PushBack(machine_to_json_value(*machine), _alloc);
}
data.AddMember("resources_data", Value().CopyFrom(resources, _alloc), _alloc);
if (machines.has_hpst_machine()) {
data.AddMember("lcst_host", machine_to_json_value(*machines.hpst_machine()), _alloc);
}
if (machines.has_pfs_machine()) {
data.AddMember("lcst_host", machine_to_json_value(*machines.pfs_machine()), _alloc);
}
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
event.AddMember("type", Value().SetString("SIMULATION_BEGINS"), _alloc);
......@@ -85,6 +89,16 @@ void JsonProtocolWriter::append_simulation_begins(Machines & machines,
_events.PushBack(event, _alloc);
}
Value JsonProtocolWriter::machine_to_json_value(const Machine & machine)
{
Value machine_doc(rapidjson::kObjectType);
machine_doc.AddMember("id", Value().SetInt(machine.id), _alloc);
machine_doc.AddMember("name", Value().SetString(machine.name.c_str(), _alloc), _alloc);
machine_doc.AddMember("state", Value().SetString(machine_state_to_string(machine.state).c_str(), _alloc), _alloc);
return machine_doc;
}
void JsonProtocolWriter::append_simulation_ends(double date)
{
/* {
......
......@@ -281,6 +281,14 @@ public:
*/
bool is_empty() { return _is_empty; }
private:
/**
* @brief Converts a machine to a json value.
* @param[in] the machine to be converted
* @return the json value
*/
rapidjson::Value machine_to_json_value(const Machine & machine);
private:
BatsimContext * _context; //!< The BatsimContext
bool _is_empty = true; //!< Stores whether events have been pushed into the writer since last clear.
......
Markdown is supported
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