Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2650#discussion_r87781042
  
    --- Diff: 
flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroupTest.java
 ---
    @@ -44,4 +52,132 @@ protected QueryScopeInfo 
createQueryServiceMetricInfo(CharacterFilter filter) {
                
                registry.shutdown();
        }
    +
    +   // for test case: one filter for different reporters with different of 
scope delimiter
    +   protected static CharacterFilter staticCharacterFilter = new 
CharacterFilter() {
    +           @Override
    +           public String filterCharacters(String input) {
    +                   return input.replace("C", "RR");
    +           }
    +   };
    +
    +   @Test
    +   public void filteringForMultipleReporters() {
    +           TestReporter1.countSuccessChecks = 0;
    +           Configuration config = new Configuration();
    +           config.setString(ConfigConstants.METRICS_SCOPE_NAMING_TM, 
"A.B.C.D");
    +           config.setString(ConfigConstants.METRICS_REPORTERS_LIST, 
"test1,test2");
    +           config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + 
"test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, 
TestReporter1.class.getName());
    +           config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + 
"test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, 
TestReporter2.class.getName());
    +           config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + 
"test1." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "-");
    +           config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + 
"test2." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "!");
    +
    +
    +           MetricRegistry testRegistry = new 
MetricRegistryTest(MetricRegistryConfiguration.fromConfiguration(config));
    +           TaskManagerMetricGroup tmGroup = new 
TaskManagerMetricGroup(testRegistry, "host", "id");
    +           tmGroup.counter(1);
    +           testRegistry.shutdown();
    +           assert TestReporter1.countSuccessChecks == 4;
    +   }
    +
    +   @Test
    +   public void filteringForNullReporters() {
    +           MetricRegistryTest.countSuccessChecks = 0;
    +           Configuration config = new Configuration();
    +           config.setString(ConfigConstants.METRICS_SCOPE_NAMING_TM, 
"A.B.C.D");
    +           MetricRegistry testRegistry = new 
MetricRegistryTest(MetricRegistryConfiguration.fromConfiguration(config));
    +           TaskManagerMetricGroup tmGroupForTestRegistry = new 
TaskManagerMetricGroup(testRegistry, "host", "id");
    +           assert testRegistry.getReporters().size() == 0;
    +           tmGroupForTestRegistry.counter(1);
    +           testRegistry.shutdown();
    +           assert MetricRegistryTest.countSuccessChecks == 1;
    +   }
    +
    +   public static class TestReporter1 extends TestReporter {
    +           protected static int countSuccessChecks = 0;
    --- End diff --
    
    we can store these in a field instead. We can retrieve all reporters from 
the registry and cast them to the required type, and use a new getter to 
retrieve the count.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to