@@ -217,82 +217,8 @@ void NotifyImp::reportNotifyInfo(const tars::ReportInfo & info, tars::TarsCurren
217
217
{
218
218
nodeId = current->getIp ();
219
219
}
220
-
221
220
switch (info.eType )
222
221
{
223
- case (REPORT):
224
- {
225
- TLOGDEBUG (" NotifyImp::reportNotifyInfo reportServer:" << info.sApp + " ." + info.sServer << " |sSet:" << info.sSet << " |sContainer:" << info.sContainer << " |ip:" << current->getHostName ()
226
- << " |nodeName:" << info.sNodeName << " |sThreadId:" << info.sThreadId << " |sMessage:" << info.sMessage << endl);
227
-
228
- if (IsNeedFilte (info.sApp + info.sServer , info.sMessage ))
229
- {
230
- TLOGWARN (" NotifyImp::reportNotifyInfo reportServer filter:" << info.sApp + " ." + info.sServer << " |sSet:" << info.sSet << " |sContainer:" << info.sContainer << " |ip:" << current->getHostName ()
231
- << " |nodeName:" << info.sNodeName << " |sThreadId:" << info.sThreadId << " |sMessage:" << info.sMessage << " |filted" << endl);
232
-
233
- return ;
234
- }
235
-
236
- string sql;
237
- TC_Mysql::RECORD_DATA rd;
238
-
239
- rd[" application" ] = make_pair (TC_Mysql::DB_STR, info.sApp );
240
- rd[" server_name" ] = make_pair (TC_Mysql::DB_STR, info.sServer );
241
- rd[" container_name" ] = make_pair (TC_Mysql::DB_STR, info.sContainer );
242
- rd[" server_id" ] = make_pair (TC_Mysql::DB_STR, info.sApp +" ." + info.sServer + " _" + nodeId);
243
- rd[" node_name" ] = make_pair (TC_Mysql::DB_STR, nodeId);
244
- rd[" thread_id" ] = make_pair (TC_Mysql::DB_STR, info.sThreadId );
245
-
246
- if (!info.sSet .empty ())
247
- {
248
- vector<string> v = TC_Common::sepstr<string>(info.sSet , " ." );
249
- if (v.size () != 3 || (v.size () == 3 && (v[0 ] == " *" || v[1 ] == " *" )))
250
- {
251
- TLOGERROR (" NotifyImp::reportNotifyInfo bad set name:" << info.sSet << endl);
252
- }
253
- else
254
- {
255
- rd[" set_name" ] = make_pair (TC_Mysql::DB_STR, v[0 ]);
256
- rd[" set_area" ] = make_pair (TC_Mysql::DB_STR, v[1 ]);
257
- rd[" set_group" ] = make_pair (TC_Mysql::DB_STR, v[2 ]);
258
- }
259
-
260
- }
261
- else
262
- {
263
- rd[" set_name" ] = make_pair (TC_Mysql::DB_STR, " " );
264
- rd[" set_area" ] = make_pair (TC_Mysql::DB_STR, " " );
265
- rd[" set_group" ] = make_pair (TC_Mysql::DB_STR, " " );
266
- }
267
-
268
- rd[" result" ] = make_pair (TC_Mysql::DB_STR, info.sMessage );
269
- rd[" notifytime" ] = make_pair (TC_Mysql::DB_INT, " now()" );
270
- string sTable = " t_server_notifys" ;
271
- try
272
- {
273
- _mysqlConfig.insertRecord (sTable , rd);
274
- }
275
- catch (TC_Mysql_Exception& ex)
276
- {
277
- string err = string (ex.what ());
278
- if (std::string::npos != err.find (" doesn't exist" ))
279
- {
280
- creatTb (sTable );
281
- }
282
- else
283
- {
284
- string sInfo = string (" insert2Db exception" ) + " |" + ServerConfig::LocalIp + " |" + ServerConfig::Application + " ." + ServerConfig::ServerName;
285
- TARS_NOTIFY_ERROR (sInfo );
286
- }
287
- TLOGERROR (" NotifyImp::reportNotifyInfo insert2Db exception:" << ex.what () << endl);
288
- }
289
- catch (exception & ex)
290
- {
291
- TLOGERROR (" NotifyImp::reportNotifyInfo insert2Db exception:" << ex.what () << endl);
292
- string sInfo = string (" insert2Db exception" ) + " |" + ServerConfig::LocalIp + " |" + ServerConfig::Application + " ." + ServerConfig::ServerName;
293
- // TARS_NOTIFY_ERROR(sInfo);
294
- }
295
- }
296
222
case (NOTIFY):
297
223
{
298
224
TLOGDEBUG (" NotifyImp::reportNotifyInfo notifyServer:" << info.sApp + " ." + info.sServer << " |sSet:" << info.sSet << " |sContainer:" << info.sContainer << " |nodeId:" << nodeId
@@ -344,8 +270,85 @@ void NotifyImp::reportNotifyInfo(const tars::ReportInfo & info, tars::TarsCurren
344
270
stInfo0.notifyItems .push_back (stItem);
345
271
iRet = g_notifyHash->set (stKey0, stInfo0);
346
272
}
347
- default :
348
- break ;
273
+ case (REPORT):
274
+ default : {
275
+ TLOGDEBUG (
276
+ " NotifyImp::reportNotifyInfo reportServer:" << info.sApp + " ." + info.sServer << " |sSet:" << info.sSet
277
+ << " |sContainer:" << info.sContainer << " |ip:"
278
+ << current->getHostName ()
279
+ << " |nodeName:" << info.sNodeName << " |sThreadId:"
280
+ << info.sThreadId << " |sMessage:" << info.sMessage << endl);
281
+
282
+ if (IsNeedFilte (info.sApp + info.sServer , info.sMessage )) {
283
+ TLOGWARN (
284
+ " NotifyImp::reportNotifyInfo reportServer filter:" << info.sApp + " ." + info.sServer << " |sSet:"
285
+ << info.sSet << " |sContainer:" << info.sContainer
286
+ << " |ip:" << current->getHostName ()
287
+ << " |nodeName:" << info.sNodeName
288
+ << " |sThreadId:" << info.sThreadId
289
+ << " |sMessage:" << info.sMessage << " |filted"
290
+ << endl);
291
+
292
+ return ;
293
+ }
294
+
295
+ string sql;
296
+ TC_Mysql::RECORD_DATA rd;
297
+
298
+ rd[" application" ] = make_pair (TC_Mysql::DB_STR, info.sApp );
299
+ rd[" server_name" ] = make_pair (TC_Mysql::DB_STR, info.sServer );
300
+ rd[" container_name" ] = make_pair (TC_Mysql::DB_STR, info.sContainer );
301
+ rd[" server_id" ] = make_pair (TC_Mysql::DB_STR, info.sApp + " ." + info.sServer + " _" + nodeId);
302
+ rd[" node_name" ] = make_pair (TC_Mysql::DB_STR, nodeId);
303
+ rd[" thread_id" ] = make_pair (TC_Mysql::DB_STR, info.sThreadId );
304
+
305
+ if (!info.sSet .empty ()) {
306
+ vector<string> v = TC_Common::sepstr<string>(info.sSet , " ." );
307
+ if (v.size () != 3 || (v.size () == 3 && (v[0 ] == " *" || v[1 ] == " *" ))) {
308
+ TLOGERROR (" NotifyImp::reportNotifyInfo bad set name:" << info.sSet << endl);
309
+ }
310
+ else {
311
+ rd[" set_name" ] = make_pair (TC_Mysql::DB_STR, v[0 ]);
312
+ rd[" set_area" ] = make_pair (TC_Mysql::DB_STR, v[1 ]);
313
+ rd[" set_group" ] = make_pair (TC_Mysql::DB_STR, v[2 ]);
314
+ }
315
+
316
+ }
317
+ else {
318
+ rd[" set_name" ] = make_pair (TC_Mysql::DB_STR, " " );
319
+ rd[" set_area" ] = make_pair (TC_Mysql::DB_STR, " " );
320
+ rd[" set_group" ] = make_pair (TC_Mysql::DB_STR, " " );
321
+ }
322
+
323
+ rd[" result" ] = make_pair (TC_Mysql::DB_STR, info.sMessage );
324
+ rd[" notifytime" ] = make_pair (TC_Mysql::DB_INT, " now()" );
325
+ string sTable = " t_server_notifys" ;
326
+ try {
327
+ _mysqlConfig.insertRecord (sTable , rd);
328
+ }
329
+ catch (TC_Mysql_Exception & ex) {
330
+ string err = string (ex.what ());
331
+ if (std::string::npos != err.find (" doesn't exist" )) {
332
+ creatTb (sTable );
333
+ }
334
+ else {
335
+ string sInfo =
336
+ string (" insert2Db exception" ) + " |" + ServerConfig::LocalIp + " |" + ServerConfig::Application
337
+ + " ." + ServerConfig::ServerName;
338
+ TARS_NOTIFY_ERROR (sInfo );
339
+ }
340
+ TLOGERROR (" NotifyImp::reportNotifyInfo insert2Db exception:" << ex.what () << endl);
341
+ }
342
+ catch (exception & ex) {
343
+ TLOGERROR (" NotifyImp::reportNotifyInfo insert2Db exception:" << ex.what () << endl);
344
+ string sInfo =
345
+ string (" insert2Db exception" ) + " |" + ServerConfig::LocalIp + " |" + ServerConfig::Application + " ."
346
+ + ServerConfig::ServerName;
347
+ }
348
+
349
+ TLOGERROR (" reportNotifyInfo unknown type:" << info.writeToJsonString () << endl);
350
+ break ;
351
+ }
349
352
}
350
353
351
354
return ;
0 commit comments