mirror of
https://gitee.com/TarsCloud/TarsCpp.git
synced 2024-12-22 22:16:38 +08:00
suport tarsnode deploy in domain
This commit is contained in:
parent
2395491d78
commit
addb77b5d5
@ -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的代理
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
@ -246,7 +246,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
set<EndpointInfo> _inactiveEndpoints;
|
set<EndpointInfo> _inactiveEndpoints;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/////////以下是请求主控的策略信息/////////////////
|
/////////以下是请求主控的策略信息/////////////////
|
||||||
|
@ -55,6 +55,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
const string &getIp() const;
|
const string &getIp() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get host name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
const string &getHostName() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取端口
|
* 获取端口
|
||||||
* @return int
|
* @return int
|
||||||
|
Loading…
Reference in New Issue
Block a user