@@ -283,111 +283,6 @@ string tostr(const set<string>& setStr)
283
283
return str;
284
284
}
285
285
286
- // string NodeServer::host2Ip(const string& host)
287
- // {
288
- // struct in_addr stSinAddr;
289
- // TC_Socket::parseAddr(host, stSinAddr);
290
- //
291
- // char ip[INET_ADDRSTRLEN] = "\0";
292
- // inet_ntop(AF_INET, &stSinAddr, ip, INET_ADDRSTRLEN);
293
- //
294
- // return ip;
295
- // }
296
- //
297
- // bool NodeServer::isValid(const string& ip)
298
- // {
299
- // static time_t g_tTime = 0;
300
- // static set<string> g_ipSet;
301
- //
302
- // time_t tNow = TNOW;
303
- //
304
- // // TLOG_DEBUG("NodeServer::isValid ip:" << ip << " -> dst:" << dst << endl);
305
- //
306
- // static TC_ThreadLock g_tMutex;
307
- //
308
- // TC_ThreadLock::Lock lock(g_tMutex);
309
- // if (tNow - g_tTime > 60)
310
- // {
311
- // string objs = g_pconf->get("/tars/node<cmd_white_list>", "tars.tarsregistry.AdminRegObj:tars.tarsAdminRegistry.AdminRegObj");
312
- // string ips = g_pconf->get("/tars/node<cmd_white_list_ip>", "");
313
- //
314
- // if(!ips.empty())
315
- // {
316
- // ips += ":";
317
- // }
318
- // ips += string("127.0.0.1:") + host2Ip(ServerConfig::LocalIp);
319
- //
320
- // TLOG_DEBUG("NodeServer::isValid objs:" << objs << "|ips:" << ips << endl);
321
- //
322
- // vector<string> vObj = TC_Common::sepstr<string>(objs, ":");
323
- //
324
- // vector<string> vIp = TC_Common::sepstr<string>(ips, ":");
325
- // for (size_t i = 0; i < vIp.size(); i++)
326
- // {
327
- // g_ipSet.insert(vIp[i]);
328
- // LOG->debug() << ips << ", g_ipSet insert ip:" << vIp[i] << endl;
329
- // }
330
- //
331
- // map<string, string> context;
332
- // //获取实际ip, 穿透代理, 给TarsCloud云使用
333
- // context["TARS_REAL"] = "true";
334
- //
335
- // QueryFPrx queryPrx = AdminProxy::getInstance()->getQueryProxy();
336
- //
337
- // for (size_t i = 0; i < vObj.size(); i++)
338
- // {
339
- // set<string> tempSet;
340
- // string obj = vObj[i];
341
- // try
342
- // {
343
- //
344
- // vector<EndpointF> vActiveEp, vInactiveEp;
345
- // queryPrx->findObjectById4All(obj, vActiveEp, vInactiveEp, context);
346
- //
347
- // for (unsigned i = 0; i < vActiveEp.size(); i++)
348
- // {
349
- // tempSet.insert(host2Ip(vActiveEp[i].host));
350
- // }
351
- //
352
- // for (unsigned i = 0; i < vInactiveEp.size(); i++)
353
- // {
354
- // tempSet.insert(host2Ip(vInactiveEp[i].host));
355
- // }
356
- //
357
- // TLOG_DEBUG("NodeServer::isValid "<< obj << "|tempSet.size():" << tempSet.size() << "|" << tostr(tempSet) << endl);
358
- // }
359
- // catch (exception& e)
360
- // {
361
- // TLOG_ERROR("NodeServer::isValid catch error: " << e.what() << endl);
362
- // }
363
- // catch (...)
364
- // {
365
- // TLOG_ERROR("NodeServer::isValid catch error: " << endl);
366
- // }
367
- //
368
- // if (tempSet.size() > 0)
369
- // {
370
- // g_ipSet.insert(tempSet.begin(), tempSet.end());
371
- // }
372
- // }
373
- //
374
- // TLOG_DEBUG("NodeServer::isValid g_ipSet.size():" << g_ipSet.size() << "|" << tostr(g_ipSet) << endl);
375
- // g_tTime = tNow;
376
- // }
377
- //
378
- // if (g_ipSet.count(ip) > 0)
379
- // {
380
- // return true;
381
- // }
382
- //
383
- // if (g_sNodeIp == ip || ServerConfig::LocalIp == ip)
384
- // {
385
- // return true;
386
- // }
387
- //
388
- // return false;
389
- // }
390
-
391
286
void NodeServer::reportServer (const string& sServerId , const string &sSet , const string &sNodeName , const string& sResult )
392
287
{
393
288
try
@@ -530,9 +425,11 @@ int NodeServer::onUpdateConfig(const string &nodeId, const string &sConfigFile,
530
425
}
531
426
532
427
string nNewLocator = getQueryEndpoint ();
533
- if (!nNewLocator.empty ())
428
+ if (!nNewLocator.empty () && nNewLocator != sLocator )
534
429
{
535
430
sLocator = nNewLocator;
431
+ CommunicatorFactory::getInstance ()->getCommunicator ()->setProperty (" locator" , sLocator );
432
+ CommunicatorFactory::getInstance ()->getCommunicator ()->reloadLocator ();
536
433
}
537
434
538
435
sTemplate = TC_Common::replace (sTemplate , " ${enableset}" , config.get (" /tars/application/server<enableset>" , " n" ));
0 commit comments