diff --git a/cpp/framework/ConfigServer/ConfigImp.cpp b/cpp/framework/ConfigServer/ConfigImp.cpp index 2e242354d..749ebd258 100644 --- a/cpp/framework/ConfigServer/ConfigImp.cpp +++ b/cpp/framework/ConfigServer/ConfigImp.cpp @@ -879,3 +879,92 @@ bool ConfigImp::IsLimited(const std::string & app, const std::string & server, c return bLimited; } +int ConfigImp::ListAllConfigByInfo(const tars::GetConfigListInfo & configInfo, vector &vf, tars::TarsCurrentPtr current) +{ + CHECKLIMIT(configInfo.appname,configInfo.servername,current->getIp(),""); + + try + { + if(configInfo.bAppOnly) + { + //查ip对应配置 + string sSql = "select distinct filename from t_config_files " + "where server_name = '" + _mysqlConfig.escapeString(configInfo.appname) + "' " + "and level=" + TC_Common::tostr(eLevelApp); + + TLOGDEBUG("ConfigImp::ListAllConfigByInfo sql:" << sSql << endl); + + TC_Mysql::MysqlData res = _mysqlConfig.queryRecord(sSql); + + TLOGDEBUG("ConfigImp::ListAllConfigByInfo sql:" << sSql << "|res:" << res.size() << endl); + + for(unsigned i=0; i(eLevelIpServer); + } + + if(!configInfo.setdivision.empty()) + { + string sSetName,sSetArea,sSetGroup; + if(getSetInfo(sSetName,sSetArea,sSetGroup,configInfo.setdivision)) + { + sCondition += " and set_name='" +_mysqlConfig.escapeString(sSetName)+"' "; + sCondition += " and set_area='" +_mysqlConfig.escapeString(sSetArea)+"' "; + sCondition += " and set_group='" +_mysqlConfig.escapeString(sSetGroup)+"' "; + } + else + { + TLOGERROR("ConfigImp::ListAllConfigByInfo setdivision is invalid:" << configInfo.setdivision << endl); + return -1; + } + } + else//兼容没有set信息的业务 + { + string sNULL; + sCondition += " and set_name='" + _mysqlConfig.escapeString(sNULL) +"' "; + sCondition += " and set_area='" + _mysqlConfig.escapeString(sNULL) +"' "; + sCondition += " and set_group='" + _mysqlConfig.escapeString(sNULL) +"' "; + } + + sSql += sCondition; + + TLOGDEBUG("ConfigImp::ListAllConfigByInfo sql:" << sSql << endl); + + TC_Mysql::MysqlData res = _mysqlConfig.queryRecord(sSql); + + TLOGDEBUG("ConfigImp::ListAllConfigByInfo sql:" << sSql << "|res:" << res.size() << endl); + + for(unsigned i=0; i &vf, tars::TarsCurrentPtr current); + protected: /** diff --git a/cpp/servant/protocol/ConfigF.tars b/cpp/servant/protocol/ConfigF.tars index 6787c10a2..c824ec57d 100644 --- a/cpp/servant/protocol/ConfigF.tars +++ b/cpp/servant/protocol/ConfigF.tars @@ -113,6 +113,14 @@ module tars * @return int 0: 合法, -1:非法 **/ int checkConfigByInfo(ConfigInfo configInfo, out string result); + + /** + * 获取服务的所有配置文件列表, + * @param configInfo 支持拉取应用配置列表,服务配置列表,机器配置列表 + * @param[out] vf 获取到的文件名称列表 + * @return int 0: 成功, -1:失败 + **/ + int ListAllConfigByInfo(GetConfigListInfo configInfo, out vector vf); }; };