예제 #1
0
std::unique_ptr<cache_config> cache_config::parse(const elliptics::config::config &cache)
{
	auto size = cache.at("size");
	if (size.as<size_t>() == 0) {
		throw elliptics::config::config_error(size.path() + " must be non-zero");
	}

	cache_config config;
	config.size = size.as<size_t>();
	config.count = cache.at<size_t>("shards", DNET_DEFAULT_CACHES_NUMBER);
	config.sync_timeout = cache.at<unsigned>("sync_timeout", DNET_DEFAULT_CACHE_SYNC_TIMEOUT_SEC);
	config.pages_proportions = cache.at("pages_proportions", std::vector<size_t>(DNET_DEFAULT_CACHE_PAGES_NUMBER, 1));
	return blackhole::utils::make_unique<cache_config>(config);
}
예제 #2
0
std::unique_ptr<monitor_config> monitor_config::parse(const elliptics::config::config &monitor)
{
	monitor_config cfg;
	cfg.monitor_port = monitor.at<unsigned int>("port", 0);

	cfg.has_top = monitor.has("top");
	if (cfg.has_top) {
		const elliptics::config::config top = monitor.at("top");
		cfg.top_length = top.at<size_t>("top_length", DNET_DEFAULT_MONITOR_TOP_LENGTH);
		cfg.events_size = top.at<size_t>("events_size", DNET_DEFAULT_MONITOR_TOP_EVENTS_SIZE);
		cfg.period_in_seconds = top.at<int>("period_in_seconds", DNET_DEFAULT_MONITOR_TOP_PERIOD);
		cfg.has_top = (cfg.top_length > 0) && (cfg.events_size > 0) && (cfg.period_in_seconds > 0);
	}
	return blackhole::utils::make_unique<monitor_config>(cfg);
}