同步操作将从 TarsCloud/Tars 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*** Tencent is pleased to support the open source community by making Tars available.** Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.** Licensed under the BSD 3-Clause License (the "License"); you may not use this file except* in compliance with the License. You may obtain a copy of the License at** https://opensource.org/licenses/BSD-3-Clause** Unless required by applicable law or agreed to in writing, software distributed* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR* CONDITIONS OF ANY KIND, either express or implied. See the License for the* specific language governing permissions and limitations under the License.*/#include "DbThread.h"#include "util/tc_config.h"#include "QueryServer.h"DBThread::DBThread(): _bTerminate(false){TLOGDEBUG("DBThread init ok" << endl);}DBThread::~DBThread(){if (isAlive()){terminate();getThreadControl().join();}TLOGDEBUG("DBThread terminate." << endl);}void DBThread::terminate(){_bTerminate = true;TC_ThreadLock::Lock lock(*this);notifyAll();}void DBThread::run(){TLOGDEBUG("DBThread::run begin." << endl);while (!_bTerminate){try{tryConnect();}catch ( exception& ex ){TLOGERROR("DBThread::run exception:" << ex.what() << endl);}catch (... ){TLOGERROR("DBThread::run unkonw exception catched" << endl);}TC_ThreadLock::Lock lock(*this);timedWait(REAP_INTERVAL);}}int DBThread::connect(MYSQL** pstMql,const TC_DBConf& tcConf){*pstMql = mysql_init(NULL);if (mysql_real_connect(*pstMql,tcConf._host.c_str(), tcConf._user.c_str(), tcConf._password.c_str(), tcConf._database.c_str(), tcConf._port, NULL, tcConf._flag) == NULL){TLOGERROR("[TC_Mysql::connect]: mysql_real_connect: " + string(mysql_error(*pstMql)) + ", erron:" <<mysql_errno(*pstMql) << " port:"<< tcConf._port << endl);return -1;}return 0;}void DBThread::sendAlarmSMS(const string &sMsg){string errInfo = " ERROR:" + ServerConfig::LocalIp + "|" + sMsg;TARS_NOTIFY_ERROR(errInfo);}void DBThread::tryConnect(){try{// vector<TC_DBConf> vDbInfo = g_app.getDbInfo();// size_t iDbInfoSize = vDbInfo.size();vector<TC_DBConf> vDbCountInfo = g_app.getDbInfo();size_t iDbCountInfoSize = vDbCountInfo.size();vector<TC_DBConf> vAtivedbCountInfo;for(size_t i = 0; i < vDbCountInfo.size(); i++){TC_DBConf tcDBConf = vDbCountInfo[i];MYSQL* _pstMql = NULL;int iRet = connect(&_pstMql,tcDBConf);if (_pstMql != NULL){mysql_close(_pstMql);_pstMql = NULL;}if (iRet != 0){TLOGERROR("DBThread::tryConnect new db host:" << tcDBConf._host << "|port:" << TC_Common::tostr(tcDBConf._port) << "|database:" << tcDBConf._database << endl);string s("host");s += tcDBConf._host;s += "|port";s += TC_Common::tostr(tcDBConf._port);s += "|database:";s += tcDBConf._database;sendAlarmSMS(s);continue;}vAtivedbCountInfo.push_back(vDbCountInfo[i]);;}size_t iActiveDbCountInfoSize = vAtivedbCountInfo.size();if(iDbCountInfoSize != iActiveDbCountInfoSize){string sMsg = "statcount old db size:";sMsg += TC_Common::tostr(iDbCountInfoSize);sMsg += "|statcount active db size:";sMsg += TC_Common::tostr(iActiveDbCountInfoSize);sMsg += "|no equal.";sendAlarmSMS(sMsg);}g_app.setActiveDb(vAtivedbCountInfo);}catch (exception& ex){TLOGERROR("DBThread::tryConnect exception:"<< ex.what() << endl);}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。