Esempio n. 1
0
int ReplicationImpl::InitFakeMaster() {
    MasterInfo info;
    int ret = master_manager_->GetMasterInfo(&info);
    if (ret) {
        ColorLogError("%s get master info fail, ret %d", __func__, ret);
        return ret;
    }

    string ip = Utils::GetIP(info.svr_id());
    if (info.svr_id() == option_->GetBinLogSvrConfig()->GetEngineSvrID()) {
        LogVerbose("%s get other ip %s", __func__, ip.c_str());
    } else {
        ctx_->SelfConn(false);
    }

    MySqlManager* mysql_manager = MySqlManager::GetGlobalMySqlManager(option_);
    if (mysql_manager->IsReplicaProcess()) {
        ip = Utils::GetIP(option_->GetBinLogSvrConfig()->GetEngineSvrID());
        ctx_->SelfConn(true);
    }

    LogVerbose("%s connect ip %s port %d", __func__, ip.c_str(), info.port());

    int master_fd = NetIO::Connect(ip.c_str(), info.port());
    if (master_fd < 0) {
		STATISTICS(ReplMySqlConnectFail());
        return SOCKET_FAIL;
    }
    return master_fd;
}
Esempio n. 2
0
bool operator == (const MasterInfo& left, const MasterInfo& right)
{
    return left.id() == right.id() &&
           left.ip() == right.ip() &&
           left.port() == right.port() &&
           left.pid() == right.pid() &&
           left.hostname() == right.hostname();
}