void meta_server_failure_detector::sync_node_state_and_start_service() { /* * we do need the failure_detector::_lock to protect, * because we want to keep the states of server_state::_nodes * and _cache_alive_nodes consistent */ zauto_lock l(failure_detector::_lock); //first add new nodes to the server_state _state->apply_cache_nodes(); //then we register all workers from server_state node_states alive_list; _state->get_node_state(alive_list); for(auto& node_pair: alive_list) { dassert(node_pair.second, "in initializing we don't add dead nodes to server_state"); // a worker may have been dead in the fd, so we must reactive it unregister_worker(node_pair.first); register_worker(node_pair.first, true); } //now nodes in server_state and in fd are in consistent state _svc->start_load_balance(); }
void meta_server_failure_detector::sync_node_state_and_start_service() { /* * we do need the failure_detector::_lock to protect, * because we want to keep the states of server_state::_nodes * and meta_service::{alive_set,dead_set} consistent */ zauto_lock l(failure_detector::_lock); std::set<rpc_address> nodes; _svc->prepare_service_starting(); _svc->get_node_state(nodes, true); for(auto& node: nodes) { // a worker may have been dead in the fd, so we must reactive it unregister_worker(node); register_worker(node, true); } //now nodes in server_state and in fd are in consistent state _svc->service_starting(); }