Commit b032a70d authored by Millian Poquet's avatar Millian Poquet

Separation of the network and the server in different files (which simplified...

Separation of the network and the server in different files (which simplified the use of XBT_LOG). Minor fixes: missing enumerated cases in string conversion, use of a switch to generate a warning on future enumerated value misses. Minor cosmetic modifications.
parent 54153030
......@@ -24,7 +24,7 @@ include_directories(${RAPIDJSON_INCLUDE_DIRS})
# Executables
add_executable(batsim batsim.cpp export.cpp ipp.cpp job_submitter.cpp jobs.cpp jobs_execution.cpp machines.cpp network.cpp profiles.cpp pstate.cpp workload.cpp context.hpp export.hpp ipp.hpp job_submitter.hpp jobs.hpp jobs_execution.hpp machines.hpp network.hpp profiles.hpp pstate.hpp workload.hpp)
add_executable(batsim batsim.cpp export.cpp ipp.cpp job_submitter.cpp jobs.cpp jobs_execution.cpp machines.cpp network.cpp profiles.cpp pstate.cpp server.cpp workload.cpp context.hpp export.hpp ipp.hpp job_submitter.hpp jobs.hpp jobs_execution.hpp machines.hpp network.hpp profiles.hpp pstate.hpp server.hpp workload.hpp)
#add_executable(batexec batexec.c job.c utils.c export.c)
# Libraries to link
......
......@@ -18,6 +18,7 @@
#include "machines.hpp"
#include "network.hpp"
#include "profiles.hpp"
#include "server.hpp"
#include "workload.hpp"
using namespace std;
......@@ -59,7 +60,7 @@ struct MainArguments
* @param[in, out] state The current argp_state
* @return 0
*/
static int parse_opt (int key, char *arg, struct argp_state *state)
int parse_opt (int key, char *arg, struct argp_state *state)
{
MainArguments * mainArgs = (MainArguments *) state->input;
......@@ -170,11 +171,6 @@ int main(int argc, char * argv[])
if (mainArgs.energy_used)
sg_energy_plugin_init();
/*QUIET,
NETWORK_ONLY,
INFORMATION,
DEBUG */
if (mainArgs.verbosity == VerbosityLevel::QUIET || mainArgs.verbosity == VerbosityLevel::NETWORK_ONLY)
{
xbt_log_control_set("workload.thresh:error");
......
#include "ipp.hpp"
#include <simgrid/msg.h>
#include <map>
using namespace std;
......@@ -23,18 +22,52 @@ void send_message(const std::string & destination_mailbox, IPMessageType type, v
std::string ipMessageTypeToString(IPMessageType type)
{
static map<IPMessageType, string> type_to_string =
string s;
switch(type)
{
{IPMessageType::JOB_SUBMITTED, "JOB_SUBMITTED"},
{IPMessageType::JOB_COMPLETED, "JOB_COMPLETED"},
{IPMessageType::SCHED_ALLOCATION, "SCHED_ALLOCATION"},
{IPMessageType::SCHED_NOP, "SCHED_NOP"},
{IPMessageType::SCHED_READY, "SCHED_READY"},
{IPMessageType::SUBMITTER_HELLO, "SUBMITTER_HELLO"},
{IPMessageType::SUBMITTER_BYE, "SUBMITTER_BYE"},
};
case IPMessageType::JOB_SUBMITTED:
s = "JOB_SUBMITTED";
break;
case IPMessageType::JOB_COMPLETED:
s = "JOB_COMPLETED";
break;
case IPMessageType::PSTATE_MODIFICATION:
s = "PSTATE_MODIFICATION";
break;
case IPMessageType::SCHED_ALLOCATION:
s = "SCHED_ALLOCATION";
break;
case IPMessageType::SCHED_REJECTION:
s = "SCHED_REJECTION";
break;
case IPMessageType::SCHED_NOP:
s = "SCHED_NOP";
break;
case IPMessageType::SCHED_NOP_ME_LATER:
s = "SCHED_NOP_ME_LATER";
break;
case IPMessageType::SCHED_READY:
s = "SCHED_READY";
break;
case IPMessageType::WAITING_DONE:
s = "WAITING_DONE";
break;
case IPMessageType::SUBMITTER_HELLO:
s = "SUBMITTER_HELLO";
break;
case IPMessageType::SUBMITTER_BYE:
s = "SUBMITTER_BYE";
break;
case IPMessageType::SWITCHED_ON:
s = "SWITCHED_ON";
break;
case IPMessageType::SWITCHED_OFF:
s = "SWITCHED_OFF";
break;
}
return type_to_string[type];
return s;
}
void send_message(const char *destination_mailbox, IPMessageType type, void *data)
......
#pragma once
#include "ipp.hpp"
#include "batsim.h"
#include "context.hpp"
int killer_process(int argc, char *argv[]);
......
#include "machines.hpp"
#include <algorithm>
#include <iterator>
#include <map>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/lexical_cast.hpp>
#include "export.hpp"
#include "context.hpp"
#include "export.hpp"
using namespace std;
......@@ -290,14 +288,28 @@ void Machines::setTracer(PajeTracer *tracer)
string machineStateToString(MachineState state)
{
static const std::map<MachineState,std::string> conv =
string s;
switch (state)
{
{MachineState::SLEEPING, "sleeping"},
{MachineState::IDLE, "idle"},
{MachineState::COMPUTING, "computing"}
};
case MachineState::SLEEPING:
s = "sleeping";
break;
case MachineState::IDLE:
s = "idle";
break;
case MachineState::COMPUTING:
s = "computing";
break;
case MachineState::TRANSITING_FROM_SLEEPING_TO_COMPUTING:
s = "sleeping->computing";
break;
case MachineState::TRANSITING_FROM_COMPUTING_TO_SLEEPING:
s = "computing->sleeping";
break;
}
return conv.at(state);
return s;
}
Machine::~Machine()
......
This diff is collapsed.
......@@ -35,5 +35,4 @@ private:
int _client_socket;
};
int uds_server_process(int argc, char *argv[]);
int request_reply_scheduler_process(int argc, char *argv[]);
This diff is collapsed.
#pragma once
int uds_server_process(int argc, char *argv[]);
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