bool c_server::LoadConfig() { CMarkupSTL config; if (!config.Load(TS_CONFIG)) return false; //根节点 config.FindElem(); if (config.FindChildElem("server", true)) { config.IntoElem(); if (config.FindChildElem("port", true)) c_config::get_instance()->m_port = atoi(config.GetChildData().c_str()); if (config.FindChildElem("threads", true)) m_threads = atoi(config.GetChildData().c_str()); if (config.FindChildElem("delay", true)) m_delay = atoi(config.GetChildData().c_str()); config.OutOfElem(); } wisdom_IOStream os = new c_ostream_array; loadStorage(os); return true; }
void c_server::loadStorage(wisdom_IOStream& os) { CMarkupSTL config; if (!config.Load(TS_CONFIG)) return; c_wlock lock(&m_lock); m_storage.clear(); //根节点 config.FindElem(); while (config.FindChildElem("storage")) { config.IntoElem(); wisdom_storage og = new _storage; og->cb = new _storage_cb; string interval; if (config.FindChildElem("interval", true)) interval = config.GetChildData().c_str(); sscanf(interval.c_str(), "%x#%x", &og->ibegin, &og->iend); if (config.FindChildElem("constr", true)) og->cb->m_constr = config.GetChildData().c_str(); LOG4_INFO("storage begin:" << og->ibegin << "|end:" << og->iend << "|constr:" << og->cb->constr()); os->push(__tos("storage begin:" << og->ibegin << "|end:" << og->iend << "|constr:" << og->cb->constr())); config.OutOfElem(); m_storage.insert(make_pair(c_interval(og->ibegin, og->iend), og)); } return; }
bool c_server::LoadConfig() { CMarkupSTL config; if (!config.Load(TS_CONFIG)) return false; //¸ù½Úµã config.FindElem(); if (config.FindChildElem("server", true)) { config.IntoElem(); if (config.FindChildElem("ip", true)) m_ip = config.GetChildData(); if (config.FindChildElem("port", true)) c_config::get_instance()->m_port = atoi(config.GetChildData().c_str()); if (config.FindChildElem("threads", true)) m_threads = atoi(config.GetChildData().c_str()); if (config.FindChildElem("leavedb", true)) m_leavedb = config.GetChildData(); if (config.FindChildElem("cache", true)) m_cache_size = atoi(config.GetChildData().c_str()); if (config.FindChildElem("list_max_count", true)) m_list_max_count = atoi(config.GetChildData().c_str()); if (config.FindChildElem("mlist_max_count", true)) m_mlist_max_count = atoi(config.GetChildData().c_str()); if (config.FindChildElem("seq_valid_time", true)) m_seq_valid_time = atoi(config.GetChildData().c_str()); if (config.FindChildElem("write_buffer_size", true)) m_write_buffer_size = atoi(config.GetChildData().c_str()); if (config.FindChildElem("object_effective", true)) m_object_effective = atoi(config.GetChildData().c_str()); if (config.FindChildElem("seq_clear_time", true)) m_seq_clear_time = atoi(config.GetChildData().c_str()); config.OutOfElem(); } return true; }