| 117 | } |
| 118 | |
| 119 | comm::RetCode Store::Init() { |
| 120 | comm::RetCode ret; |
| 121 | |
| 122 | if (impl_->opt.log_func) { |
| 123 | comm::Logger::GetInstance()->SetLogFunc(impl_->opt.log_func); |
| 124 | } |
| 125 | |
| 126 | if (impl_->opt.config_factory_create_func) { |
| 127 | plugin::ConfigFactory::SetConfigFactoryCreateFunc(impl_->opt.config_factory_create_func); |
| 128 | } |
| 129 | |
| 130 | if (impl_->opt.break_point_factory_create_func) { |
| 131 | plugin::BreakPointFactory::SetBreakPointFactoryCreateFunc(impl_->opt.break_point_factory_create_func); |
| 132 | } |
| 133 | |
| 134 | if (!comm::utils::AccessDir(impl_->opt.data_dir_path)) { |
| 135 | QLErr("path %s not exist", impl_->opt.data_dir_path.c_str()); |
| 136 | return comm::RetCode::RET_DIR_NOT_EXIST; |
| 137 | } |
| 138 | |
| 139 | impl_->addr.set_ip(impl_->opt.ip); |
| 140 | impl_->addr.set_port(impl_->opt.port); |
| 141 | impl_->addr.set_paxos_port(impl_->opt.paxos_port); |
| 142 | |
| 143 | if (comm::RetCode::RET_OK != (ret = InitTopicID())) { |
| 144 | QLErr("InitTopicID ret %d topic %s", as_integer(ret), impl_->opt.topic.c_str()); |
| 145 | return ret; |
| 146 | } |
| 147 | |
| 148 | comm::StoreBP::GetThreadInstance()->OnInit(impl_->topic_id); |
| 149 | |
| 150 | QLVerb("ip %s port %d paxos_port %d", impl_->opt.ip.c_str(), |
| 151 | impl_->opt.port, impl_->opt.paxos_port); |
| 152 | |
| 153 | impl_->basemgr = unique_ptr<BaseMgr>(new BaseMgr(this)); |
| 154 | if (comm::RetCode::RET_OK != (ret = impl_->basemgr->Init())) { |
| 155 | comm::StoreBP::GetThreadInstance()->OnInitErrBaseMgr(impl_->topic_id); |
| 156 | QLErr("basemgr Init ret %d", as_integer(ret)); |
| 157 | return ret; |
| 158 | } |
| 159 | |
| 160 | impl_->sync = unique_ptr<SyncCtrl>(new SyncCtrl(this)); |
| 161 | if (comm::RetCode::RET_OK != (ret = impl_->sync->Init())) { |
| 162 | comm::StoreBP::GetThreadInstance()->OnInitErrSyncCtrl(impl_->topic_id); |
| 163 | QLErr("sync Init ret %d", as_integer(ret)); |
| 164 | return ret; |
| 165 | } |
| 166 | |
| 167 | impl_->cpmgr = unique_ptr<CheckPointStatMgr>(new CheckPointStatMgr(this)); |
| 168 | if (comm::RetCode::RET_OK != (ret = impl_->cpmgr->Init())) { |
| 169 | comm::StoreBP::GetThreadInstance()->OnInitErrCPMgr(impl_->topic_id); |
| 170 | QLErr("cpmgr Init ret %d", as_integer(ret)); |
| 171 | return ret; |
| 172 | } |
| 173 | |
| 174 | impl_->keep_sync_thread = unique_ptr<KeepSyncThread>(new KeepSyncThread(this)); |
| 175 | impl_->keep_master_thread = unique_ptr<KeepMasterThread>(new KeepMasterThread(this)); |
| 176 |
nothing calls this directly
no test coverage detected