98 lines
2.8 KiB
C
98 lines
2.8 KiB
C
|
/*************************************************************************
|
||
|
> File Name : CConfig.h
|
||
|
> Author : FengChao
|
||
|
> EMail : smile.fengchao@gmail.com
|
||
|
> Created Time : Fri 17 Jul 2020 09:31:50 AM CST
|
||
|
************************************************************************/
|
||
|
|
||
|
#include <iostream>
|
||
|
#include <stdio.h>
|
||
|
#include <string>
|
||
|
#include <string.h>
|
||
|
#include "CJudgeUtils.h"
|
||
|
#include "CTypedef.h"
|
||
|
|
||
|
class Config : public CSingleton<Config>
|
||
|
{
|
||
|
public:
|
||
|
Config() {}
|
||
|
virtual ~Config() {}
|
||
|
|
||
|
void Init(const std::string& file_name)
|
||
|
{
|
||
|
INIReader reader;
|
||
|
reader.Parse(file_name);
|
||
|
|
||
|
std::string strNosIdx;
|
||
|
for(int i = 0; i < NOS_MAX_NUM; i++)
|
||
|
{
|
||
|
strNosIdx.clear();
|
||
|
strNosIdx = "nos" + std::to_string((i + 1)) + "_ip";
|
||
|
nos_ip[i] = reader.Get("judge", strNosIdx, strNosIdx);
|
||
|
}
|
||
|
|
||
|
#define _GET_JUDGE_CFG(value) value = reader.GetInt32("judge", #value, value)
|
||
|
_GET_JUDGE_CFG(schedule_port);
|
||
|
_GET_JUDGE_CFG(pluginsctrl_port);
|
||
|
_GET_JUDGE_CFG(sub_nos_state_port);
|
||
|
_GET_JUDGE_CFG(nos_num);
|
||
|
_GET_JUDGE_CFG(running_num);
|
||
|
|
||
|
#undef _GET_JUDGE_CFG
|
||
|
|
||
|
#define _GET_JUDGE_CFG(value) value = reader.Get("judge", #value, value)
|
||
|
_GET_JUDGE_CFG(config_manager_ip);
|
||
|
_GET_JUDGE_CFG(schedule_ip);
|
||
|
_GET_JUDGE_CFG(pluginsctrl_ip);
|
||
|
|
||
|
#undef _GET_JUDGE_CFG
|
||
|
|
||
|
// Judge_sys_info
|
||
|
#define _GET_JUDGE_SYS_INFO_CFG(value) value = reader.GetInt32("judge_sys_info", #value, value)
|
||
|
_GET_JUDGE_SYS_INFO_CFG(nos_monitor_port);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(cpu_occupy_max);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(mem_occupy_max);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(tcp_socket_max);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(progress_max);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(cron_max);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(path_file_max);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(home_file_max);
|
||
|
|
||
|
#undef _GET_JUDGE_SYS_INFO_CFG
|
||
|
|
||
|
#define _GET_JUDGE_SYS_INFO_CFG(value) value = reader.Get("judge_sys_info", #value, value)
|
||
|
_GET_JUDGE_SYS_INFO_CFG(user_md5);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(group_md5);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(config_manager_md5);
|
||
|
_GET_JUDGE_SYS_INFO_CFG(auto_start_md5);
|
||
|
|
||
|
#undef _GET_JUDGE_SYS_INFO_CFG
|
||
|
}
|
||
|
|
||
|
std::string nos_ip[NOS_MAX_NUM];
|
||
|
std::string config_manager_ip;
|
||
|
std::string schedule_ip;
|
||
|
std::string pluginsctrl_ip;
|
||
|
|
||
|
int sub_nos_state_port;
|
||
|
int schedule_port;
|
||
|
int pluginsctrl_port;
|
||
|
int nos_num;
|
||
|
int running_num;
|
||
|
|
||
|
// Judge_sys_info
|
||
|
std::string user_md5;
|
||
|
std::string group_md5;
|
||
|
std::string config_manager_md5;
|
||
|
std::string auto_start_md5;
|
||
|
|
||
|
int nos_monitor_port;
|
||
|
int cpu_occupy_max;
|
||
|
int mem_occupy_max;
|
||
|
int tcp_socket_max;
|
||
|
int progress_max;
|
||
|
int cron_max;
|
||
|
int path_file_max;
|
||
|
int home_file_max;
|
||
|
};
|