Merge branch 'ruanshudong_dev'

This commit is contained in:
ruanshudong 2020-03-25 17:56:07 +08:00
commit 79bc349737
14 changed files with 80 additions and 53 deletions

View File

@ -14,6 +14,12 @@ ENDIF()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin)
endforeach()
set(_USE_OPENTRACKING $ENV{_USE_OPENTRACKING}) set(_USE_OPENTRACKING $ENV{_USE_OPENTRACKING})
if(_USE_OPENTRACKING) if(_USE_OPENTRACKING)
@ -74,11 +80,7 @@ ELSE ()
ENDIF (UNIX) ENDIF (UNIX)
#------------------------------------------------------------- #-------------------------------------------------------------
IF(WIN32)
set(TARS2CPP "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/tars2cpp.exe")
ELSE()
set(TARS2CPP "${CMAKE_BINARY_DIR}/bin/tars2cpp") set(TARS2CPP "${CMAKE_BINARY_DIR}/bin/tars2cpp")
ENDIF()
message("----------------------------------------------------") message("----------------------------------------------------")

View File

@ -74,11 +74,11 @@ if (WIN32)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR} PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND cmake . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/gtest CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/gtest
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gtest-lib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gtest-lib
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
BUILD_COMMAND cmake --build . --config release BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release
INSTALL_COMMAND cmake --build . --config release --target install INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install
# LOG_CONFIGURE 1 # LOG_CONFIGURE 1
# LOG_BUILD 1 # LOG_BUILD 1
URL_MD5 82358affdd7ab94854c8ee73a180fc53 URL_MD5 82358affdd7ab94854c8ee73a180fc53
@ -89,13 +89,13 @@ else()
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR} PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND cmake . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/gtest CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/gtest
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gtest-lib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gtest-lib
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
BUILD_COMMAND make BUILD_COMMAND make
# LOG_CONFIGURE 1 # LOG_CONFIGURE 1
# LOG_BUILD 1 # LOG_BUILD 1
# INSTALL_COMMAND cmake -P ${RUN_PROTOBUF_INSTALL_FILE} # INSTALL_COMMAND ${CMAKE_COMMAND} -P ${RUN_PROTOBUF_INSTALL_FILE}
URL_MD5 ecd1fa65e7de707cd5c00bdac56022cd URL_MD5 ecd1fa65e7de707cd5c00bdac56022cd
) )
endif() endif()
@ -122,13 +122,13 @@ if (TARS_PROTOBUF)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR} PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND cmake cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON CONFIGURE_COMMAND ${CMAKE_COMMAND} cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/protobuf-lib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/protobuf-lib
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
BUILD_COMMAND cmake --build . --config release BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release
# LOG_CONFIGURE 1 # LOG_CONFIGURE 1
# LOG_BUILD 1 # LOG_BUILD 1
INSTALL_COMMAND cmake --build . --config release --target install INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install
URL_MD5 fb59398329002c98d4d92238324c4187 URL_MD5 fb59398329002c98d4d92238324c4187
) )
else () else ()
@ -140,13 +140,13 @@ if (TARS_PROTOBUF)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR} PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND cmake cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DBUILD_SHARED_LIBS=OFF CONFIGURE_COMMAND ${CMAKE_COMMAND} cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DBUILD_SHARED_LIBS=OFF
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/protobuf-lib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/protobuf-lib
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
BUILD_COMMAND make BUILD_COMMAND make
# LOG_CONFIGURE 1 # LOG_CONFIGURE 1
# LOG_BUILD 1 # LOG_BUILD 1
# INSTALL_COMMAND cmake -P ${RUN_PROTOBUF_INSTALL_FILE} # INSTALL_COMMAND ${CMAKE_COMMAND} -P ${RUN_PROTOBUF_INSTALL_FILE}
URL_MD5 fb59398329002c98d4d92238324c4187 URL_MD5 fb59398329002c98d4d92238324c4187
) )
@ -200,7 +200,7 @@ if (TARS_SSL)
BUILD_COMMAND make BUILD_COMMAND make
# LOG_CONFIGURE 1 # LOG_CONFIGURE 1
# LOG_BUILD 1 # LOG_BUILD 1
# INSTALL_COMMAND cmake -P ${RUN_SSL_INSTALL_FILE} # INSTALL_COMMAND ${CMAKE_COMMAND} -P ${RUN_SSL_INSTALL_FILE}
URL_MD5 3be209000dbc7e1b95bcdf47980a3baa URL_MD5 3be209000dbc7e1b95bcdf47980a3baa
) )
@ -226,13 +226,13 @@ if (TARS_MYSQL)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR} PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND cmake . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DBUILD_CONFIG=mysql_release CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DBUILD_CONFIG=mysql_release
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/mysql-lib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/mysql-lib
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
BUILD_COMMAND cmake --build . --config release BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release
# LOG_CONFIGURE 1 # LOG_CONFIGURE 1
# LOG_BUILD 1 # LOG_BUILD 1
INSTALL_COMMAND cmake --build . --config release --target install INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install
URL_MD5 62de01beffc48348708c983a585b4dc1 URL_MD5 62de01beffc48348708c983a585b4dc1
) )
@ -244,13 +244,13 @@ if (TARS_MYSQL)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR} PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND cmake . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDISABLE_SHARED=1 CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDISABLE_SHARED=1
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/mysql-lib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/mysql-lib
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
BUILD_COMMAND make mysqlclient BUILD_COMMAND make mysqlclient
# LOG_CONFIGURE 1 # LOG_CONFIGURE 1
# LOG_BUILD 1 # LOG_BUILD 1
# INSTALL_COMMAND cmake --build . --config release --target install # INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install
URL_MD5 98ca2071f9d4c6b73146cc0455f6b914 URL_MD5 98ca2071f9d4c6b73146cc0455f6b914
) )
@ -280,13 +280,13 @@ if (TARS_HTTP2)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR} PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND cmake . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/nghttp2 -DENABLE_LIB_ONLY=ON -DENABLE_STATIC_LIB=ON CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/nghttp2 -DENABLE_LIB_ONLY=ON -DENABLE_STATIC_LIB=ON
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/nghttp2-lib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/nghttp2-lib
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
# LOG_BUILD 1 # LOG_BUILD 1
# LOG_CONFIGURE 1 # LOG_CONFIGURE 1
BUILD_COMMAND cmake --build . --config release BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release
INSTALL_COMMAND cmake --build . --config release --target install INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install
URL_MD5 5df375bbd532fcaa7cd4044b54b1188d URL_MD5 5df375bbd532fcaa7cd4044b54b1188d
) )
@ -296,7 +296,7 @@ if (TARS_HTTP2)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR} PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND cmake . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/nghttp2 -DENABLE_LIB_ONLY=ON -DENABLE_STATIC_LIB=ON CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/nghttp2 -DENABLE_LIB_ONLY=ON -DENABLE_STATIC_LIB=ON
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/nghttp2-lib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/nghttp2-lib
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
# LOG_BUILD 1 # LOG_BUILD 1

View File

@ -97,6 +97,7 @@ std::string ServerConfig::Key;
bool ServerConfig::VerifyClient = false; bool ServerConfig::VerifyClient = false;
#endif #endif
map<string, string> ServerConfig::Context;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
TC_Config Application::_conf; TC_Config Application::_conf;
@ -475,7 +476,7 @@ bool Application::cmdLoadProperty(const string& command, const string& params, s
ServerConfig::Config = _conf.get("/tars/application/server<config>"); ServerConfig::Config = _conf.get("/tars/application/server<config>");
TarsRemoteConfig::getInstance()->setConfigInfo(_communicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath,setDivision()); TarsRemoteConfig::getInstance()->setConfigInfo(_communicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath,setDivision(), 5);
ServerConfig::Notify = _conf.get("/tars/application/server<notify>"); ServerConfig::Notify = _conf.get("/tars/application/server<notify>");
@ -1049,6 +1050,7 @@ void Application::initializeServer()
ServerConfig::BackPacketLimit = TC_Common::strto<int>(_conf.get("/tars/application/server<backpacketlimit>", "100*1024*1024")); ServerConfig::BackPacketLimit = TC_Common::strto<int>(_conf.get("/tars/application/server<backpacketlimit>", "100*1024*1024"));
ServerConfig::BackPacketMin = TC_Common::strto<int>(_conf.get("/tars/application/server<backpacketmin>", "1024")); ServerConfig::BackPacketMin = TC_Common::strto<int>(_conf.get("/tars/application/server<backpacketmin>", "1024"));
ServerConfig::Context["node_name"] = ServerConfig::LocalIp;
#if TARS_SSL #if TARS_SSL
ServerConfig::CA = _conf.get("/tars/application/server<ca>"); ServerConfig::CA = _conf.get("/tars/application/server<ca>");
ServerConfig::Cert = _conf.get("/tars/application/server<cert>"); ServerConfig::Cert = _conf.get("/tars/application/server<cert>");
@ -1149,7 +1151,7 @@ void Application::initializeServer()
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
//初始化到信息中心代理 //初始化到信息中心代理
cout << OUT_LINE << "\n" << TC_Common::outfill("[set remote notify] ") << "OK" << endl; cout << OUT_LINE << "\n" << TC_Common::outfill("[set remote notify] ") << "OK" << endl;
TarsRemoteNotify::getInstance()->setNotifyInfo(_communicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, setDivision()); TarsRemoteNotify::getInstance()->setNotifyInfo(_communicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, setDivision(), ServerConfig::LocalIp);
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
//初始化到Node的代理 //初始化到Node的代理

View File

@ -389,16 +389,16 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName)
{ {
case E_ALL: case E_ALL:
{ {
iRet = _queryFPrx->findObjectById4Any(_objName,activeEp,inactiveEp); iRet = _queryFPrx->findObjectById4Any(_objName,activeEp,inactiveEp, ServerConfig::Context);
break; break;
} }
case E_STATION: case E_STATION:
{ {
iRet = _queryFPrx->findObjectByIdInSameStation(_objName,sName,activeEp,inactiveEp); iRet = _queryFPrx->findObjectByIdInSameStation(_objName,sName,activeEp,inactiveEp, ServerConfig::Context);
} }
case E_SET: case E_SET:
{ {
iRet = _queryFPrx->findObjectByIdInSameSet(_objName,sName,activeEp,inactiveEp); iRet = _queryFPrx->findObjectByIdInSameSet(_objName,sName,activeEp,inactiveEp, ServerConfig::Context);
break; break;
} }
case E_DEFAULT: case E_DEFAULT:
@ -408,11 +408,11 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName)
{ {
//指定set调用时指定set的优先级最高 //指定set调用时指定set的优先级最高
string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId;
iRet = _queryFPrx->findObjectByIdInSameSet(_objName,setId,activeEp,inactiveEp); iRet = _queryFPrx->findObjectByIdInSameSet(_objName,setId,activeEp,inactiveEp, ServerConfig::Context);
} }
else else
{ {
iRet = _queryFPrx->findObjectByIdInSameGroup(_objName,activeEp,inactiveEp); iRet = _queryFPrx->findObjectByIdInSameGroup(_objName,activeEp,inactiveEp, ServerConfig::Context);
} }
break; break;
} }
@ -425,17 +425,17 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName)
{ {
case E_ALL: case E_ALL:
{ {
_queryFPrx->async_findObjectById4Any(this,_objName); _queryFPrx->async_findObjectById4Any(this,_objName, ServerConfig::Context);
break; break;
} }
case E_STATION: case E_STATION:
{ {
_queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName); _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName, ServerConfig::Context);
break; break;
} }
case E_SET: case E_SET:
{ {
_queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName); _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName, ServerConfig::Context);
break; break;
} }
case E_DEFAULT: case E_DEFAULT:
@ -445,11 +445,11 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName)
{ {
//指定set调用时指定set的优先级最高 //指定set调用时指定set的优先级最高
string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId;
_queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId); _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId, ServerConfig::Context);
} }
else else
{ {
_queryFPrx->async_findObjectByIdInSameGroup(this,_objName); _queryFPrx->async_findObjectByIdInSameGroup(this,_objName, ServerConfig::Context);
} }
break; break;
} }

View File

@ -19,6 +19,7 @@
#include "util/tc_timeprovider.h" #include "util/tc_timeprovider.h"
#include "servant/TarsLogger.h" #include "servant/TarsLogger.h"
#include "servant/Communicator.h" #include "servant/Communicator.h"
#include "servant/Application.h"
#include <iostream> #include <iostream>
namespace tars namespace tars
@ -36,7 +37,7 @@ StatReport::StatReport(size_t iEpollNum)
, _epollNum(iEpollNum) , _epollNum(iEpollNum)
, _retValueNumLimit(10) , _retValueNumLimit(10)
{ {
srand(time(NULL)); srand(time(NULL));
for(size_t i = 0 ; i < _epollNum; i++) for(size_t i = 0 ; i < _epollNum; i++)
{ {
@ -477,7 +478,7 @@ int StatReport::reportMicMsg(MapStatMicMsg& msg,bool bFromClient)
if(_statPrx) if(_statPrx)
{ {
TLOGTARS("[TARS][StatReport::reportMicMsg send size:" << mTemp.size()<<"]"<< endl); TLOGTARS("[TARS][StatReport::reportMicMsg send size:" << mTemp.size()<<"]"<< endl);
_statPrx->tars_set_timeout(_reportTimeout)->async_reportMicMsg(NULL,mTemp,bFromClient); _statPrx->tars_set_timeout(_reportTimeout)->async_reportMicMsg(NULL,mTemp,bFromClient, ServerConfig::Context);
} }
iLen = iTemLen; iLen = iTemLen;
mTemp.clear(); mTemp.clear();
@ -499,7 +500,7 @@ int StatReport::reportMicMsg(MapStatMicMsg& msg,bool bFromClient)
if(_statPrx) if(_statPrx)
{ {
TLOGTARS("[TARS][StatReport::reportMicMsg send size:" << mTemp.size()<<"]"<< endl); TLOGTARS("[TARS][StatReport::reportMicMsg send size:" << mTemp.size()<<"]"<< endl);
_statPrx->tars_set_timeout(_reportTimeout)->async_reportMicMsg(NULL,mTemp,bFromClient); _statPrx->tars_set_timeout(_reportTimeout)->async_reportMicMsg(NULL,mTemp,bFromClient, ServerConfig::Context);
} }
} }
return 0; return 0;
@ -690,7 +691,7 @@ int StatReport::reportSampleMsg()
if(_statPrx) if(_statPrx)
{ {
TLOGTARS("[TARS][StatReport::reportSampleMsg send size:" << vTemp.size()<< "]"<< endl); TLOGTARS("[TARS][StatReport::reportSampleMsg send size:" << vTemp.size()<< "]"<< endl);
_statPrx->tars_set_timeout(_reportTimeout)->async_reportSampleMsg(NULL,vTemp); _statPrx->tars_set_timeout(_reportTimeout)->async_reportSampleMsg(NULL,vTemp, ServerConfig::Context);
} }
iLen = iTemLen; iLen = iTemLen;
vTemp.clear(); vTemp.clear();
@ -702,7 +703,7 @@ int StatReport::reportSampleMsg()
if(_statPrx) if(_statPrx)
{ {
TLOGTARS("[TARS][StatReport::reportSampleMsg send size:" << vTemp.size()<< "]"<< endl); TLOGTARS("[TARS][StatReport::reportSampleMsg send size:" << vTemp.size()<< "]"<< endl);
_statPrx->tars_set_timeout(_reportTimeout)->async_reportSampleMsg(NULL,vTemp); _statPrx->tars_set_timeout(_reportTimeout)->async_reportSampleMsg(NULL,vTemp, ServerConfig::Context);
} }
} }

View File

@ -18,6 +18,7 @@
#include "util/tc_file.h" #include "util/tc_file.h"
#include "servant/Communicator.h" #include "servant/Communicator.h"
#include "servant/TarsNotify.h" #include "servant/TarsNotify.h"
#include "servant/Application.h"
#include <fstream> #include <fstream>
namespace tars namespace tars
@ -108,7 +109,7 @@ string TarsRemoteConfig::getRemoteFile(const string &sFileName, bool bAppConfigO
{ {
if(_setdivision.empty()) if(_setdivision.empty())
{ {
ret = _configPrx->loadConfig(_app, (bAppConfigOnly ? "" : _serverName), sFileName, stream); ret = _configPrx->loadConfig(_app, (bAppConfigOnly ? "" : _serverName), sFileName, stream, ServerConfig::Context);
} }
else else
{ {
@ -118,7 +119,7 @@ string TarsRemoteConfig::getRemoteFile(const string &sFileName, bool bAppConfigO
confInfo.filename = sFileName; confInfo.filename = sFileName;
confInfo.bAppOnly = bAppConfigOnly; confInfo.bAppOnly = bAppConfigOnly;
confInfo.setdivision = _setdivision; confInfo.setdivision = _setdivision;
ret = _configPrx->loadConfigByInfo(confInfo,stream); ret = _configPrx->loadConfigByInfo(confInfo,stream, ServerConfig::Context);
} }
break; break;

View File

@ -60,10 +60,20 @@ TarsCurrent::~TarsCurrent()
} }
} }
const string &TarsCurrent::getHostName() const
{
auto it = _request.context.find("node_name");
if(it != _request.context.end())
{
return it->second;
}
return _data->ip();
}
const string &TarsCurrent::getIp() const const string &TarsCurrent::getIp() const
{ {
return _data->ip(); return _data->ip();
// return _ip;
} }
int TarsCurrent::getPort() const int TarsCurrent::getPort() const

View File

@ -84,7 +84,7 @@ void RollWriteT::operator()(ostream &of, const deque<pair<size_t, string> > &ds)
{ {
try try
{ {
_logPrx->logger(DYEING_DIR, DYEING_FILE, "roll", "%Y%m%d", vRemoteDyeing); _logPrx->logger(DYEING_DIR, DYEING_FILE, "roll", "%Y%m%d", vRemoteDyeing, ServerConfig::Context);
} }
catch(exception &ex) catch(exception &ex)
{ {
@ -254,7 +254,7 @@ void RemoteTimeWriteT::sync2remote(const vector<string> &v)
stInfo.sSepar = _timeWrite->_separ; stInfo.sSepar = _timeWrite->_separ;
stInfo.sLogType = _timeWrite->_logType; stInfo.sLogType = _timeWrite->_logType;
_timeWrite->_logPrx->loggerbyInfo(stInfo,v); _timeWrite->_logPrx->loggerbyInfo(stInfo,v, ServerConfig::Context);
if (_timeWrite->_reportSuccPtr) if (_timeWrite->_reportSuccPtr)
{ {
@ -276,7 +276,7 @@ void RemoteTimeWriteT::sync2remoteDyeing(const vector<string> &v)
{ {
try try
{ {
_timeWrite->_logPrx->logger(DYEING_DIR, DYEING_FILE, "", _timeWrite->_format, v); _timeWrite->_logPrx->logger(DYEING_DIR, DYEING_FILE, "", _timeWrite->_format, v, ServerConfig::Context);
} }
catch(exception &ex) catch(exception &ex)
{ {
@ -418,7 +418,7 @@ void TimeWriteT::operator()(ostream &of, const deque<pair<size_t, string> > &buf
{ {
try try
{ {
_logPrx->logger(DYEING_DIR, DYEING_FILE, "day", "%Y%m%d", vDyeingLog); _logPrx->logger(DYEING_DIR, DYEING_FILE, "day", "%Y%m%d", vDyeingLog, ServerConfig::Context);
} }
catch(exception &ex) catch(exception &ex)
{ {

View File

@ -140,6 +140,7 @@ struct ServerConfig
static std::string Key; static std::string Key;
static bool VerifyClient; static bool VerifyClient;
#endif #endif
static map<string, string> Context; //框架内部用, 传递节点名称(以域名形式部署时)
}; };
class PropertyReport; class PropertyReport;

View File

@ -246,7 +246,6 @@ protected:
*/ */
set<EndpointInfo> _inactiveEndpoints; set<EndpointInfo> _inactiveEndpoints;
private: private:
/////////以下是请求主控的策略信息///////////////// /////////以下是请求主控的策略信息/////////////////

View File

@ -57,7 +57,7 @@ public:
* *
* @return int * @return int
*/ */
int setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string& basePath,const string& setdivision="",int maxBakNum=5); int setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string& basePath,const string& setdivision="",int maxBakNum = 5);
/** /**
* ConfigServer上配置文件到本地 * ConfigServer上配置文件到本地

View File

@ -56,6 +56,12 @@ public:
const string &getIp() const; const string &getIp() const;
/** /**
* get host name
* @return
*/
const string &getHostName() const;
/**
* *
* @return int * @return int
*/ */

View File

@ -529,7 +529,7 @@ public:
* @param server, * @param server,
* @param logpath, * @param logpath,
*/ */
void setLogInfo(const CommunicatorPtr &comm, const string &obj, const string &sApp, const string &sServer, const string &sLogpath,const string& setdivision="", const bool &bLogStatReport = false); void setLogInfo(const CommunicatorPtr &comm, const string &obj, const string &sApp, const string &sServer, const string &sLogpath,const string& setdivision="", const bool &bLogStatReport=false);
/** /**
* ("%Y%m%d") * ("%Y%m%d")

View File

@ -6,7 +6,12 @@ include_directories(${util_SOURCE_DIR}/include)
link_libraries(tarsutil) link_libraries(tarsutil)
function(tars2language TARGET) function(tars2language TARGET)
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin") set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin)
endforeach()
include_directories(${PROJECT_SOURCE_DIR}/tarsparse) include_directories(${PROJECT_SOURCE_DIR}/tarsparse)