Monitor::preinit

2019-07-14 12:50发布

class="markdown_views prism-atom-one-light"> int Monitor::preinit() |---r = sanitize_options() |---g_conf->mon_lease_renew_interval_factor //必须小于1.0 |---g_conf->mon_lease_ack_timeout_factor // 必须大于1.0 |---PerfCountersBuilder pcb(g_ceph_context, "mon", l_mon_first, l_mon_last); |---构造时 m_perf_counters(new PerfCounters(cct, name, first, last)) // PerfCounters 私有构造 ?? // typedef std::vector perf_counter_data_vec_t |--- m_data.resize(upper_bound - lower_bound - 1) // vector重置元素个数 |---logger = pcb.create_perf_counters(); |---PerfCounters *ret = m_perf_counters // logger指向 m_perf_counters, 通过外部指针访问类的私有变量 |---cct->get_perfcounters_collection()->add(logger) |---插入 m_loggers |---PerfCountersBuilder pcb(g_ceph_context, "cluster", l_cluster_first, l_cluster_last); |---cluster_logger = pcb.create_perf_counters(); |---paxos->init_logger() |---pcb.set_prio_default(PerfCountersBuilder::PRIO_USEFUL) |---pcb.add_u64_counter |---logger = pcb.create_perf_counters() |---g_ceph_context->get_perfcounters_collection()->add(logger) |---r = check_fsid() |---read_features(); |---read_features_off_disk(store, &features) |---store->get(MONITOR_NAME, COMPAT_SET_LOC, featuresbl) // 读取不到 |---features->encode(featuresbl) |---store->apply_transaction(t) // 读取到了 |---features->decode(it) |---calc_quorum_requirements() |---has_ever_joined = (store->get(MONITOR_NAME, "joined") != 0) |---if (!has_ever_joined) // 没有加入过 quorum |---get_str_list(g_conf->mon_initial_members, initial_members) // initial_members 不为空。 |---monmap->set_initial_members(g_ceph_context, initial_members, name, messenger->get_myaddr(), &extra_probe_peers) |---mon不在initial_members,则将其插入extra_probe_peers |----initial_members中的mon不存在于mon_info中,则将其加入mon_info // 本节点没有在monmap中 |--- |---if (store->exists("mon_sync", "in_sync")) |---if (store->get("mon_sync", "force_sync") > 0) |---if (clear_store) |---sync_last_committed_floor = store->get("mon_sync", "last_committed_floor") |---init_paxos() |---paxos->init() |---上次当选leader时产生的PN,下次当选继续产生 |---接受的最后一个PN(来源未知) |---最后一次commit的paxos id |---日志中最早commit的paxos id(并不一定是第一个) |---for (int i = 0; i < PAXOS_NUM; ++i) |---调用paxos_service中的各个init |---refresh_from_paxos(NULL) |---health_monitor->init(); |---if (is_keyring_required()) |---if (authmon()->get_last_committed() == 0) |--- |--- |---r = keyring.load(cct, keyring_loc) |--- |--- |---admin_hook = new AdminHook(this); |---AdminSocket* admin_socket = cct->get_admin_socket(); |---r = admin_socket->register_command("mon_status", "mon_status", admin_hook, "show current monitor status"); |---g_conf->add_observer(this);