fix notify, support nodeid is domain

This commit is contained in:
ruanshudong 2020-01-20 09:12:41 +08:00
parent d11e66222c
commit 6921007b29
6 changed files with 50 additions and 41 deletions

View File

@ -40,3 +40,4 @@ set(TARS2CPP "${tools_BINARY_DIR}/tars2cpp/tars2cpp")
add_subdirectory(servant) add_subdirectory(servant)
#add_subdirectory(test_deprecated)

View File

@ -427,7 +427,7 @@ bool Application::cmdLoadProperty(const string& command, const string& params, s
ServerConfig::Notify = _conf.get("/tars/application/server<notify>"); ServerConfig::Notify = _conf.get("/tars/application/server<notify>");
TarsRemoteNotify::getInstance()->setNotifyInfo(_communicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, setDivision()); TarsRemoteNotify::getInstance()->setNotifyInfo(_communicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::LocalIp, setDivision());
result = "loaded config items:\r\n" + sResult + result = "loaded config items:\r\n" + sResult +
"log=" + ServerConfig::Log + "\r\n" + "log=" + ServerConfig::Log + "\r\n" +

View File

@ -21,7 +21,7 @@
namespace tars namespace tars
{ {
int TarsRemoteNotify::setNotifyInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string &sSetName) int TarsRemoteNotify::setNotifyInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string &sSetName, const string &nodeName)
{ {
_comm = comm; _comm = comm;
if(!obj.empty()) if(!obj.empty())
@ -33,7 +33,7 @@ int TarsRemoteNotify::setNotifyInfo(const CommunicatorPtr &comm, const string &o
_setName = sSetName; _setName = sSetName;
_app = app; _app = app;
_serverName = serverName; _serverName = serverName;
_nodeName = nodeName;
return 0; return 0;
} }
@ -49,6 +49,7 @@ void TarsRemoteNotify::report(const string &sResult, bool bSync)
info.sSet = _setName; info.sSet = _setName;
info.sThreadId = TC_Common::tostr(pthread_self()); info.sThreadId = TC_Common::tostr(pthread_self());
info.sMessage = sResult; info.sMessage = sResult;
info.sNodeName = _nodeName;
if(!bSync) if(!bSync)
{ {
//_notifyPrx->async_reportServer(NULL, _app + "." + _serverName, TC_Common::tostr(pthread_self()), sResult); //_notifyPrx->async_reportServer(NULL, _app + "." + _serverName, TC_Common::tostr(pthread_self()), sResult);
@ -85,6 +86,7 @@ void TarsRemoteNotify::notify(NOTIFYLEVEL level, const string &sMessage)
info.sThreadId = TC_Common::tostr(pthread_self()); info.sThreadId = TC_Common::tostr(pthread_self());
info.sMessage = sMessage; info.sMessage = sMessage;
info.eLevel = level; info.eLevel = level;
info.sNodeName = _nodeName;
//_notifyPrx->async_notifyServer(NULL, _app + "." + _serverName, level, sMessage); //_notifyPrx->async_notifyServer(NULL, _app + "." + _serverName, level, sMessage);
_notifyPrx->async_reportNotifyInfo(NULL, info); _notifyPrx->async_reportNotifyInfo(NULL, info);
} }
@ -99,34 +101,34 @@ void TarsRemoteNotify::notify(NOTIFYLEVEL level, const string &sMessage)
} }
} }
void TarsRemoteNotify::report(const string &sMessage, const string & app, const string &serverName, const string &sNodeName) // void TarsRemoteNotify::report(const string &sMessage, const string & app, const string &serverName, const string &sNodeName)
{ // {
try // try
{ // {
if(_notifyPrx) // if(_notifyPrx)
{ // {
ReportInfo info; // ReportInfo info;
// info.eType = 0; // // info.eType = 0;
info.sApp = app; // info.sApp = app;
info.sServer = serverName; // info.sServer = serverName;
info.sSet = ""; // info.sSet = "";
info.sThreadId = "";//TC_Common::tostr(pthread_self()); // info.sThreadId = "";//TC_Common::tostr(pthread_self());
info.sMessage = sMessage; // info.sMessage = sMessage;
info.sNodeName = sNodeName; // info.sNodeName = sNodeName;
// info.eLevel = level; // // info.eLevel = level;
//_notifyPrx->async_notifyServer(NULL, _app + "." + _serverName, level, sMessage); // //_notifyPrx->async_notifyServer(NULL, _app + "." + _serverName, level, sMessage);
_notifyPrx->async_reportNotifyInfo(NULL, info); // _notifyPrx->async_reportNotifyInfo(NULL, info);
} // }
} // }
catch(exception &ex) // catch(exception &ex)
{ // {
TLOGERROR("TarsRemoteNotify::notify error:" << ex.what() << endl); // TLOGERROR("TarsRemoteNotify::notify error:" << ex.what() << endl);
} // }
catch(...) // catch(...)
{ // {
TLOGERROR("TarsRemoteNotify::notify unknown error" << endl); // TLOGERROR("TarsRemoteNotify::notify unknown error" << endl);
} // }
} // }
} }

@ -1 +1 @@
Subproject commit c8739b8a82b37c83def57cc5ed48f03eff4dec1b Subproject commit da4f37c6c349383686571c221190b4315db06a4b

View File

@ -43,7 +43,7 @@ public:
* *
* @return int * @return int
*/ */
int setNotifyInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string &sSetName=""); int setNotifyInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string &nodeName, const string &sSetName="");
/** /**
* , * ,
@ -62,7 +62,7 @@ public:
* , * ,
* @param message * @param message
*/ */
void report(const string &sMesage, const string & app, const string &serverName, const string &sNodeName); // void report(const string &sMesage, const string & app, const string &serverName, const string &sNodeName);
protected: protected:
/** /**
@ -88,7 +88,12 @@ protected:
/* /*
*set *set
*/ */
string _setName; string _setName;
/*
*
*/
string _nodeName;
}; };
} }

View File

@ -89,13 +89,14 @@ int main(int argc, char *argv[])
// cout << TC_File::getFileSize("./test_tc_file.cpp") << endl; // cout << TC_File::getFileSize("./test_tc_file.cpp") << endl;
// cout << TC_File::isFileExist("./test_tc_file.cpp", S_IFDIR) << endl; // cout << TC_File::isFileExist("./test_tc_file.cpp", S_IFDIR) << endl;
// cout << TC_File::makeDir("test") << endl; // cout << TC_File::makeDir("test") << endl;
cout << TC_File::simplifyDirectory("/.") << endl; // cout << TC_File::simplifyDirectory("/.") << endl;
cout << TC_File::simplifyDirectory("/./ab/tt//t///t//../tt/") << endl; // cout << TC_File::simplifyDirectory("/./ab/tt//t///t//../tt/") << endl;
TC_File::removeFile("./", true); // TC_File::removeFile("./", true);
vector<string> v; // vector<string> v;
TC_File::listDirectory("/home/base.l", v, true); // TC_File::listDirectory("/home/base.l", v, true);
for_each(v.begin(), v.end(), Out()); // for_each(v.begin(), v.end(), Out());
TC_File::copyFile("/data/shared/Tars/web/", "/home/tars/", true);
// TC_File::removeFile("/home/base.l", false); // TC_File::removeFile("/home/base.l", false);
} }