@@ -380,6 +380,60 @@ public void testSlowLogFilters() throws Exception {
380380 HBASE_TESTING_UTILITY .waitFor (3000 , () -> getSlowLogPayloads (requestSlowLog ).size () == 15 ));
381381 }
382382
383+ @ Test
384+ public void testSlowLogFilterWithClientAddress () throws Exception {
385+ Configuration conf = applySlowLogRecorderConf (10 );
386+ Constructor <NamedQueueRecorder > constructor =
387+ NamedQueueRecorder .class .getDeclaredConstructor (Configuration .class );
388+ constructor .setAccessible (true );
389+ namedQueueRecorder = constructor .newInstance (conf );
390+ AdminProtos .SlowLogResponseRequest request =
391+ AdminProtos .SlowLogResponseRequest .newBuilder ().build ();
392+ Assert .assertEquals (getSlowLogPayloads (request ).size (), 0 );
393+
394+ String [] clientAddressArray = new String [] { "[127:1:1:1:1:1:1:1]:1" , "[127:1:1:1:1:1:1:1]:2" ,
395+ "[127:1:1:1:1:1:1:1]:3" , "127.0.0.1:1" , "127.0.0.1:2" };
396+ boolean isSlowLog ;
397+ boolean isLargeLog ;
398+ for (int i = 0 ; i < 10 ; i ++) {
399+ if (i % 2 == 0 ) {
400+ isSlowLog = true ;
401+ isLargeLog = false ;
402+ } else {
403+ isSlowLog = false ;
404+ isLargeLog = true ;
405+ }
406+ RpcLogDetails rpcLogDetails = getRpcLogDetails ("userName_" + (i + 1 ),
407+ clientAddressArray [i % 5 ], "class_" + (i + 1 ), isSlowLog , isLargeLog );
408+ namedQueueRecorder .addRecord (rpcLogDetails );
409+ }
410+
411+ AdminProtos .SlowLogResponseRequest largeLogRequestIPv6WithPort =
412+ AdminProtos .SlowLogResponseRequest .newBuilder ()
413+ .setLogType (AdminProtos .SlowLogResponseRequest .LogType .LARGE_LOG )
414+ .setClientAddress ("[127:1:1:1:1:1:1:1]:2" ).build ();
415+ Assert .assertNotEquals (-1 , HBASE_TESTING_UTILITY .waitFor (3000 ,
416+ () -> getSlowLogPayloads (largeLogRequestIPv6WithPort ).size () == 1 ));
417+ AdminProtos .SlowLogResponseRequest largeLogRequestIPv6WithoutPort =
418+ AdminProtos .SlowLogResponseRequest .newBuilder ()
419+ .setLogType (AdminProtos .SlowLogResponseRequest .LogType .LARGE_LOG )
420+ .setClientAddress ("[127:1:1:1:1:1:1:1]" ).build ();
421+ Assert .assertNotEquals (-1 , HBASE_TESTING_UTILITY .waitFor (3000 ,
422+ () -> getSlowLogPayloads (largeLogRequestIPv6WithoutPort ).size () == 3 ));
423+ AdminProtos .SlowLogResponseRequest largeLogRequestIPv4WithPort =
424+ AdminProtos .SlowLogResponseRequest .newBuilder ()
425+ .setLogType (AdminProtos .SlowLogResponseRequest .LogType .LARGE_LOG )
426+ .setClientAddress ("127.0.0.1:1" ).build ();
427+ Assert .assertNotEquals (-1 , HBASE_TESTING_UTILITY .waitFor (3000 ,
428+ () -> getSlowLogPayloads (largeLogRequestIPv4WithPort ).size () == 1 ));
429+ AdminProtos .SlowLogResponseRequest largeLogRequestIPv4WithoutPort =
430+ AdminProtos .SlowLogResponseRequest .newBuilder ()
431+ .setLogType (AdminProtos .SlowLogResponseRequest .LogType .LARGE_LOG )
432+ .setClientAddress ("127.0.0.1" ).build ();
433+ Assert .assertNotEquals (-1 , HBASE_TESTING_UTILITY .waitFor (3000 ,
434+ () -> getSlowLogPayloads (largeLogRequestIPv4WithoutPort ).size () == 2 ));
435+ }
436+
383437 @ Test
384438 public void testConcurrentSlowLogEvents () throws Exception {
385439
0 commit comments