Skip to content

Commit

Permalink
fix tarsnode, when tarsregistry all down, tarsnode still can start local
Browse files Browse the repository at this point in the history
servers
  • Loading branch information
ruanshudong committed Nov 2, 2023
1 parent f966581 commit 626596b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
28 changes: 12 additions & 16 deletions NodeServer/KeepAliveThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,16 @@ void KeepAliveThread::run()

int64_t updateConfigTime = TNOW;

do
{
//wait for access registry success!
_registryPrx = AdminProxy::getInstance()->getRegistryProxy();
try
{
_registryPrx->tars_set_timeout(1000)->tars_ping();
break;
}
catch (exception &ex)
{
NODE_LOG("KeepAliveThread")->error() << FILE_FUN << "catch exception:" << ex.what() << endl;
}
}while(true);
_registryPrx = AdminProxy::getInstance()->getRegistryProxy();
try
{
_registryPrx->tars_set_timeout(1000)->tars_ping();
}
catch (exception &ex)
{
NODE_LOG("KeepAliveThread")->error() << FILE_FUN << "catch exception:" << ex.what() << endl;
TC_Common::sleep(1);
}

while (!_terminate)
{
Expand Down Expand Up @@ -210,7 +206,7 @@ bool KeepAliveThread::registerNode()

bool KeepAliveThread::loadAllServers()
{
NODE_LOG("KeepAliveThread")->debug() << FILE_FUN << "load server begin===============|node name|" << _nodeInfo.nodeName << endl;
NODE_LOG("KeepAliveThread")->debug() << FILE_FUN << "load server begin, node name: " << _nodeInfo.nodeName << endl;

/**
* 由于加载失败或者node下没有部署服务,这里就会一直去访问主控
Expand Down Expand Up @@ -260,7 +256,7 @@ int KeepAliveThread::reportAlive()
{
tReport = tNow;

NODE_LOG("KeepAliveThread")->debug() << FILE_FUN << "node keep alive time:" << TNOW << ", thread id:" << TC_Thread::CURRENT_THREADID() << endl;
NODE_LOG("KeepAliveThread")->debug() << FILE_FUN << "node keep alive time:" << TC_Common::tm2str(TNOW, "%Y-%m-%dT%H:%M:%S") << ", thread id:" << TC_Thread::CURRENT_THREADID() << endl;

int iRet = _registryPrx->keepAlive(_nodeInfo.nodeName, _platformInfo.getLoadInfo());

Expand Down
4 changes: 2 additions & 2 deletions NodeServer/ServerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ServerObjectPtr ServerFactory::loadServer( const string& application, const stri
serverId = "KeepAliveThread";
}

NODE_LOG(serverId)->debug() << "loadServer: '" << application << "." << serverName << "', enableCache:" << enableCache << endl;
NODE_LOG(serverId)->debug() << "loadServer: '" << (application.empty()?"all node servers" : serverId) << "', enableCache:" << enableCache << endl;

ServerObjectPtr pServerObjectPtr;
vector<ServerDescriptor> vServerDescriptor;
Expand Down Expand Up @@ -150,7 +150,7 @@ vector<ServerDescriptor> ServerFactory::getServerFromRegistry( const string& app
vector<ServerDescriptor> vServerDescriptor;
try
{
NODE_LOG(serverId)->debug() << FILE_FUN << "app.server: '" << application << "." << serverName << "', nodeName:" << _tPlatformInfo.getNodeName() << endl;
NODE_LOG(serverId)->debug() << FILE_FUN << "app.server: '" << (application.empty()?"all node servers" : serverId) << "', nodeName:" << _tPlatformInfo.getNodeName() << endl;

RegistryPrx _pRegistryPrx = AdminProxy::getInstance()->getRegistryProxy();

Expand Down
1 change: 0 additions & 1 deletion deploy/linux-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

if (( $# < 7 ))
then
echo $#
echo "$0 MYSQL_IP MYSQL_PASSWORD INET REBUILD(true/false) SLAVE(false[default]/true) MYSQL_USER MYSQL_PORT OVERWRITE(false/true[default]) NODE_MIRROR(tencentcloud[default]/aliyun)";
exit 1
fi
Expand Down

0 comments on commit 626596b

Please sign in to comment.