MCPcopy Create free account
hub / github.com/Tencent/phxqueue / Init

Method Init

phxqueue/lock/lock.cpp:79–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79comm::RetCode Lock::Init() {
80 if (impl_->opt.log_func) {
81 comm::Logger::GetInstance()->SetLogFunc(impl_->opt.log_func);
82 }
83
84 if (impl_->opt.config_factory_create_func) {
85 plugin::ConfigFactory::SetConfigFactoryCreateFunc(impl_->opt.config_factory_create_func);
86 }
87
88 if (impl_->opt.break_point_factory_create_func) {
89 plugin::BreakPointFactory::SetBreakPointFactoryCreateFunc(impl_->opt.break_point_factory_create_func);
90 }
91
92 impl_->addr.set_ip(impl_->opt.ip);
93 impl_->addr.set_port(impl_->opt.port);
94 impl_->addr.set_paxos_port(impl_->opt.paxos_port);
95
96
97 comm::RetCode ret{InitTopicID()};
98 if (comm::RetCode::RET_OK != ret) {
99 QLErr("InitTopicID ret %d", as_integer(ret));
100
101 return ret;
102 }
103
104 comm::LockBP::GetThreadInstance()->OnInit(impl_->topic_id);
105
106 // init data path
107 auto mirror_dir_path(impl_->opt.data_dir_path + "/mirror/");
108 if (!comm::utils::CreateDir(mirror_dir_path)) {
109 QLErr("mirror_dir_path %s not exist", mirror_dir_path.c_str());
110 return comm::RetCode::RET_DIR_NOT_EXIST;
111 }
112
113 impl_->lock_mgr = unique_ptr<LockMgr>(new LockMgr(this));
114 if (comm::RetCode::RET_OK != (ret = impl_->lock_mgr->Init(mirror_dir_path))) {
115 QLErr("lock_mgr Init ret %d", as_integer(ret));
116
117 return ret;
118 }
119
120 impl_->clean_thread = unique_ptr<CleanThread>(new CleanThread(this));
121 impl_->keep_master_thread = unique_ptr<KeepMasterThread>(new KeepMasterThread(this));
122
123 ret = PaxosInit(mirror_dir_path);
124 if (comm::RetCode::RET_OK != ret) {
125 QLErr("PaxosInit ret %d", as_integer(ret));
126
127 return ret;
128 }
129
130 impl_->clean_thread->Run();
131 impl_->keep_master_thread->Run();
132
133 return comm::RetCode::RET_OK;
134}
135
136comm::RetCode Lock::Dispose() {

Callers 5

mainFunction · 0.45
SchedulerRunFunction · 0.45
LockRunFunction · 0.45
StoreRunFunction · 0.45
mainFunction · 0.45

Calls 5

as_integerFunction · 0.85
CreateDirFunction · 0.85
SetLogFuncMethod · 0.80
OnInitMethod · 0.45
RunMethod · 0.45

Tested by 5

mainFunction · 0.36
SchedulerRunFunction · 0.36
LockRunFunction · 0.36
StoreRunFunction · 0.36
mainFunction · 0.36