Exemple #1
0
int UsrAccConfig::deal_mem(const std::string &line, const int &pos) {
	std::string key;
	std::string value;
	get_key_value(line, pos, key, value);
	if (key == "tid_num_seg") {
		// to do ...
		std::string tmp = "";
		TidParam tid_param;
		while ((tmp = split_first(value, ";")) != "")
		{
			std::string tmp2 = split_first(tmp, ":");
			CommonLogger::instance().log_info(" tmp is %s", tmp.c_str());
			CommonLogger::instance().log_info(" tmp2 is %s", tmp2.c_str());
			if (tmp2 != "" && tmp != "")
			{
				tid_param.min_tid = atoi(tmp2.c_str());
				tid_param.max_tid = atoi(tmp.c_str());
				tid_num_seg_list_.push_back(tid_param);
			}
		}
		if (value != "")
		{
			std::string tmp = split_first(value, ":");
			if (tmp != "" && value != "")
			{
				tid_param.min_tid = atoi(tmp.c_str());
				tid_param.max_tid = atoi(value.c_str());
				tid_num_seg_list_.push_back(tid_param);
			}
		}
	} else if (key == "usr_count") {
		usr_count_ = atoi(value.c_str());
	} else if (key == "usr_hash_count") {
		usr_hash_count_ = atoi(value.c_str());
	} else if (key == "app_req_queue_block_num") {
		app_req_queue_block_num_ = atoi(value.c_str());
	} else if (key == "app_req_queue_block_size") {
		app_req_queue_block_size_ = atoi(value.c_str());
	} else if (key == "servlogic_req_queue_block_num") {
		servlogic_req_queue_block_num_ = atoi(value.c_str());
	} else if (key == "servlogic_req_queue_block_size") {
		servlogic_req_queue_block_size_ = atoi(value.c_str());
	} else if (key == "user_op_queue_block_num") {
		user_op_queue_block_num_ = atoi(value.c_str());
	} else if (key == "user_op_queue_block_size") {
		user_op_queue_block_size_ = atoi(value.c_str());
	} else {
		printf("unknown key \" %s \" in section \" MEM \".\n", key.c_str());
		return -1;
	}
	return 0;
}
Exemple #2
0
int UsrAccConfig::deal_serv_logic(const std::string &line, const int &pos) {
	std::string key;
	std::string value;
	get_key_value(line,pos,key,value);
	if (key == "serv_logic_server") {
		// todo ...
		std::string tmp = "";
		ServerInfo server_info;
		while ((tmp = split_first(value, ";")) != "")
		{
			std::string tmp2 = split_first(tmp, ":");
			if (tmp2 != "" && tmp != "")
			{
				server_info.ip = tmp2;
				server_info.port = atoi(tmp.c_str());
				serv_logic_server_list_.push_back(server_info);
			}
		}
		if (value != "")
		{
			std::string tmp = split_first(value, ":");
			if (tmp != "" && value != "")
			{
				server_info.ip = tmp;
				server_info.port = atoi(value.c_str());
				serv_logic_server_list_.push_back(server_info);
			}
		}
	} else if (key == "heartbeat_timeinterval") {
		heartbeat_timeinterval_ = atoi(value.c_str());
	} else {
		printf("unknown key \" %s \" in section \" CecsInfo \".\n", key.c_str());
		return -1;
	}
	return 0;
}
Exemple #3
0
inline std::vector<std::string> split(const std::string& str, const std::string& sep) {
  std::vector<std::string> substr;
  substr.push_back(str);
  std::string last_substr(str);
  if (sep.empty()) {
    return substr;
  }
  do {
    auto split = split_first(last_substr, sep);
    substr[substr.size()-1] = split.first;
    substr.push_back(split.second);
    last_substr = substr[substr.size()-1];
  } while(!last_substr.empty());
  substr.pop_back();
  return substr;
}