MCPcopy Create free account
hub / github.com/Tencent/phxsql / InitFakeMaster

Method InitFakeMaster

phxbinlogsvr/core/repl/replication_impl.cpp:91–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91int ReplicationImpl::InitFakeMaster() {
92 MasterInfo info;
93 int ret = master_manager_->GetMasterInfo(&info);
94 if (ret) {
95 ColorLogError("%s get master info fail, ret %d", __func__, ret);
96 return ret;
97 }
98
99 string ip = Utils::GetIP(info.svr_id());
100 if (info.svr_id() == option_->GetBinLogSvrConfig()->GetEngineSvrID()) {
101 LogVerbose("%s get other ip %s", __func__, ip.c_str());
102 } else {
103 ctx_->SelfConn(false);
104 }
105
106 MySqlManager* mysql_manager = MySqlManager::GetGlobalMySqlManager(option_);
107 if (mysql_manager->IsReplicaProcess()) {
108 ip = Utils::GetIP(option_->GetBinLogSvrConfig()->GetEngineSvrID());
109 ctx_->SelfConn(true);
110 }
111
112 LogVerbose("%s connect ip %s port %d", __func__, ip.c_str(), info.port());
113
114 int master_fd = NetIO::Connect(ip.c_str(), info.port());
115 if (master_fd < 0) {
116 STATISTICS(ReplMySqlConnectFail());
117 return SOCKET_FAIL;
118 }
119 return master_fd;
120}
121
122}
123

Callers

nothing calls this directly

Calls 7

ColorLogErrorFunction · 0.85
LogVerboseFunction · 0.85
GetMasterInfoMethod · 0.80
GetEngineSvrIDMethod · 0.80
GetBinLogSvrConfigMethod · 0.80
SelfConnMethod · 0.80
IsReplicaProcessMethod · 0.80

Tested by

no test coverage detected