Commit 13d29d00 authored by Millian Poquet's avatar Millian Poquet
Browse files

Travis utf8+log, general log++

parent cbeceb88
...@@ -50,7 +50,7 @@ find_package(SimGrid REQUIRED) ...@@ -50,7 +50,7 @@ find_package(SimGrid REQUIRED)
include_directories(${SIMGRID_INCLUDE_DIR}) include_directories(${SIMGRID_INCLUDE_DIR})
## Boost dependency ## Boost dependency
find_package(Boost 1.48 REQUIRED COMPONENTS system filesystem regex) find_package(Boost 1.48 REQUIRED COMPONENTS system filesystem regex locale)
include_directories(${Boost_INCLUDE_DIR}) include_directories(${Boost_INCLUDE_DIR})
## Rapidjson dependency ## Rapidjson dependency
...@@ -82,9 +82,10 @@ add_executable(batsim ${batsim_SRC}) ...@@ -82,9 +82,10 @@ add_executable(batsim ${batsim_SRC})
# Libraries to link # Libraries to link
target_link_libraries(batsim ${SIMGRID_LIBRARIES} target_link_libraries(batsim ${SIMGRID_LIBRARIES}
${Boost_SYSTEM_LIBRARY_DEBUG}
${Boost_FILESYSTEM_LIBRARY_DEBUG} ${Boost_FILESYSTEM_LIBRARY_DEBUG}
${Boost_LOCALE_LIBRARY_DEBUG}
${Boost_REGEX_LIBRARY_DEBUG} ${Boost_REGEX_LIBRARY_DEBUG}
${Boost_SYSTEM_LIBRARY_DEBUG}
${REDOX_LIBRARY} ${REDOX_LIBRARY}
${LIBEV_LIBRARY} ${LIBEV_LIBRARY}
${HIREDIS_LIBRARY}) ${HIREDIS_LIBRARY})
......
...@@ -271,38 +271,23 @@ int main(int argc, char * argv[]) ...@@ -271,38 +271,23 @@ int main(int argc, char * argv[])
if (mainArgs.energy_used) if (mainArgs.energy_used)
sg_energy_plugin_init(); sg_energy_plugin_init();
vector<string> log_categories_to_set = {"workload", "job_submitter", "redis", "jobs", "batsim", "machines", "pstate",
"workflow", "jobs_execution", "server", "export", "profiles", "machine_range",
"network", "ipp"};
string log_threshold_to_set = "info";
if (mainArgs.verbosity == VerbosityLevel::QUIET || mainArgs.verbosity == VerbosityLevel::NETWORK_ONLY) if (mainArgs.verbosity == VerbosityLevel::QUIET || mainArgs.verbosity == VerbosityLevel::NETWORK_ONLY)
{ log_threshold_to_set = "error";
xbt_log_control_set("workload.thresh:error");
xbt_log_control_set("jobs.thresh:error");
xbt_log_control_set("batsim.thresh:error");
xbt_log_control_set("machines.thresh:error");
xbt_log_control_set("pstate.thresh:error");
xbt_log_control_set("jobs_execution.thresh:error");
xbt_log_control_set("export.thresh:error");
xbt_log_control_set("profiles.thresh:error");
xbt_log_control_set("network.thresh:error");
xbt_log_control_set("server.thresh:error");
xbt_log_control_set("ipp.thresh:error");
}
if (mainArgs.verbosity == VerbosityLevel::NETWORK_ONLY) if (mainArgs.verbosity == VerbosityLevel::NETWORK_ONLY)
{
xbt_log_control_set("network.thresh:info"); xbt_log_control_set("network.thresh:info");
}
else if (mainArgs.verbosity == VerbosityLevel::DEBUG) else if (mainArgs.verbosity == VerbosityLevel::DEBUG)
log_threshold_to_set = "debug";
for (const auto & log_cat : log_categories_to_set)
{ {
xbt_log_control_set("workload.thresh:debug"); const string final_str = log_cat + ".thresh:" + log_threshold_to_set;
xbt_log_control_set("jobs.thresh:debug"); xbt_log_control_set(final_str.c_str());
xbt_log_control_set("batsim.thresh:debug");
xbt_log_control_set("machines.thresh:debug");
xbt_log_control_set("pstate.thresh:debug");
xbt_log_control_set("jobs_execution.thresh:debug");
xbt_log_control_set("export.thresh:debug");
xbt_log_control_set("profiles.thresh:debug");
xbt_log_control_set("network.thresh:debug");
xbt_log_control_set("server.thresh:debug");
xbt_log_control_set("ipp.thresh:debug");
} }
// Initialization // Initialization
......
...@@ -145,6 +145,11 @@ const std::map<int, Job* > &Jobs::jobs() const ...@@ -145,6 +145,11 @@ const std::map<int, Job* > &Jobs::jobs() const
return _jobs; return _jobs;
} }
int Jobs::nb_jobs() const
{
return _jobs.size();
}
bool job_comparator_subtime(const Job *a, const Job *b) bool job_comparator_subtime(const Job *a, const Job *b)
{ {
return a->submission_time < b->submission_time; return a->submission_time < b->submission_time;
...@@ -212,9 +217,7 @@ Job * Job::from_json(const rapidjson::Value & json_desc, Workload * workload) ...@@ -212,9 +217,7 @@ Job * Job::from_json(const rapidjson::Value & json_desc, Workload * workload)
j->json_description = boost::regex_replace(json_description_tmp, r, replacement_str); j->json_description = boost::regex_replace(json_description_tmp, r, replacement_str);
XBT_DEBUG("Loaded job %d from workload %s", (int) j->number, j->workload->name.c_str() );
XBT_INFO("Loaded job %d from workload %s. The remainder of this string is just here to explicit the Black Hole issue (#1).", (int) j->number, j->workload->name.c_str() );
return j; return j;
} }
......
...@@ -172,6 +172,12 @@ public: ...@@ -172,6 +172,12 @@ public:
*/ */
const std::map<int, Job*> & jobs() const; const std::map<int, Job*> & jobs() const;
/**
* @brief Returns the number of jobs of the Jobs instance
* @return the number of jobs of the Jobs instance
*/
int nb_jobs() const;
private: private:
std::map<int, Job*> _jobs; //!< The std::map which contains the jobs std::map<int, Job*> _jobs; //!< The std::map which contains the jobs
Profiles * _profiles = nullptr; //!< The profiles associated with the jobs Profiles * _profiles = nullptr; //!< The profiles associated with the jobs
......
...@@ -107,6 +107,11 @@ const std::map<std::string, Profile *> Profiles::profiles() const ...@@ -107,6 +107,11 @@ const std::map<std::string, Profile *> Profiles::profiles() const
return _profiles; return _profiles;
} }
int Profiles::nb_profiles() const
{
return _profiles.size();
}
MsgParallelProfileData::~MsgParallelProfileData() MsgParallelProfileData::~MsgParallelProfileData()
{ {
......
...@@ -182,6 +182,12 @@ public: ...@@ -182,6 +182,12 @@ public:
*/ */
const std::map<std::string, Profile *> profiles() const; const std::map<std::string, Profile *> profiles() const;
/**
* @brief Returns the number of profiles of the Profiles instance
* @return The number of profiles of the Profiles instance
*/
int nb_profiles() const;
private: private:
std::map<std::string, Profile*> _profiles; //!< Stores all the profiles, indexed by their names std::map<std::string, Profile*> _profiles; //!< Stores all the profiles, indexed by their names
}; };
...@@ -5,10 +5,14 @@ ...@@ -5,10 +5,14 @@
#include "storage.hpp" #include "storage.hpp"
#include <boost/locale.hpp>
#include <xbt.h> #include <xbt.h>
using namespace std; using namespace std;
XBT_LOG_NEW_DEFAULT_CATEGORY(redis, "redis"); //!< Logging
RedisStorage::RedisStorage() RedisStorage::RedisStorage()
{ {
//TODO: wrap redox logging into simgrid? //TODO: wrap redox logging into simgrid?
...@@ -51,13 +55,37 @@ void RedisStorage::disconnect() ...@@ -51,13 +55,37 @@ void RedisStorage::disconnect()
std::string RedisStorage::get(const std::string & key) std::string RedisStorage::get(const std::string & key)
{ {
xbt_assert(_is_connected, "Bad RedisStorage::get call: Not connected"); xbt_assert(_is_connected, "Bad RedisStorage::get call: Not connected");
return _redox.get(build_key(key));
string real_key = boost::locale::conv::to_utf<char>(build_key(key), "UTF-8");
try
{
return _redox.get(real_key);
}
catch (const std::exception & e)
{
XBT_ERROR("Couldn't get the value associated to key '%s' in Redis! "
"Message: %s", real_key.c_str(), e.what());
return "";
}
} }
bool RedisStorage::set(const std::string &key, const std::string &value) bool RedisStorage::set(const std::string &key, const std::string &value)
{ {
string real_key = boost::locale::conv::to_utf<char>(build_key(key), "UTF-8");
string real_value = boost::locale::conv::to_utf<char>(value, "UTF-8");
xbt_assert(_is_connected, "Bad RedisStorage::get call: Not connected"); xbt_assert(_is_connected, "Bad RedisStorage::get call: Not connected");
return _redox.set(build_key(key), value); bool ret = _redox.set(real_key, real_value);
if (ret)
{
XBT_INFO("Set: '%s'='%s'", real_key.c_str(), real_value.c_str());
xbt_assert(get(key) == value, "Batsim <-> Redis communications are inconsistent!");
}
else
XBT_WARN("Couldn't set: '%s'='%s'", real_key.c_str(), real_value.c_str());
return ret;
} }
bool RedisStorage::del(const std::string &key) bool RedisStorage::del(const std::string &key)
......
...@@ -72,7 +72,8 @@ void Workload::load_from_json(const std::string &json_filename, int &nb_machines ...@@ -72,7 +72,8 @@ void Workload::load_from_json(const std::string &json_filename, int &nb_machines
jobs->load_from_json(doc, json_filename); jobs->load_from_json(doc, json_filename);
profiles->load_from_json(doc, json_filename); profiles->load_from_json(doc, json_filename);
XBT_INFO("JSON workload parsed sucessfully."); XBT_INFO("JSON workload parsed sucessfully. Read %d jobs and %d profiles.",
jobs->nb_jobs(), profiles->nb_profiles());
XBT_INFO("Checking workload validity..."); XBT_INFO("Checking workload validity...");
check_validity(); check_validity();
XBT_INFO("Workload seems to be valid."); XBT_INFO("Workload seems to be valid.");
...@@ -265,7 +266,7 @@ Job *Workloads::add_job_if_not_exists(const JobIdentifier &job_id, BatsimContext ...@@ -265,7 +266,7 @@ Job *Workloads::add_job_if_not_exists(const JobIdentifier &job_id, BatsimContext
Job * job = nullptr; Job * job = nullptr;
if (!workload->jobs->exists(job_id.job_number)) if (!workload->jobs->exists(job_id.job_number))
{ {
XBT_INFO("CREATING JOB %d FOR WORKLOAD %s",job_id.job_number, workload->name.c_str()); XBT_INFO("CREATING JOB %d FOR WORKLOAD %s",job_id.job_number, workload->name.c_str());
job = Job::from_json(job_json_description, workload); job = Job::from_json(job_json_description, workload);
xbt_assert(job_id.job_number == job->number, xbt_assert(job_id.job_number == job->number,
"Cannot add dynamic job %s!%d: JSON job number mismatch (%d)", "Cannot add dynamic job %s!%d: JSON job number mismatch (%d)",
......
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