shenzhu commented on a change in pull request #16750:
URL: https://github.com/apache/flink/pull/16750#discussion_r685238750



##########
File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/TwoInputStreamTaskTest.java
##########
@@ -473,7 +473,7 @@ public void testOperatorMetricReuse() throws Exception {
                     @Override
                     public OperatorMetricGroup getOrAddOperator(
                             OperatorID operatorID, String name) {
-                        return new OperatorMetricGroup(
+                        return OperatorMetricGroup.createOperatorMetricGroup(

Review comment:
       > Let's do it like this instead:
   > 
   > ```
   > final TaskMetricGroup taskMetricGroup =
   >         MetricUtils.createTaskManagerMetricGroup(
   >                 NoOpMetricRegistry.INSTANCE,
   >                 "host",
   >                 ResourceID.generate())
   >         .addTaskForJob(
   >                 new JobID(),
   >                 "jobname",
   >                 new JobVertexID(),
   >                 new ExecutionAttemptID(),
   >                 "task",
   >                 0,
   >                 0))
   > ```
   > 
   > The current is exactly the kind of hacks that I want to get rid of.
   > 
   > This way we also won't need `createOperatorMetricGroup`.
   
   Got it, I will update here, thanks!
   
   Hey Chesnay, sorry I have one question...how should we handle [this test 
case](https://github.com/apache/flink/blob/master/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/MultipleInputStreamTaskTest.java#L402)?
 Which requires creating an `OperatorMetricGroup` explicitly and put it in 
[operatorMetrics](https://github.com/apache/flink/blob/master/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/MultipleInputStreamTaskTest.java#L392),
 without constructor 
[getOrAddOperator](https://github.com/apache/flink/blob/1027acd61f8e2c067b20d287dcca3eb5557b9319/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroup.java#L151)
 is the only function we could use to create `OperatorMetricGroup`, but in this 
test we are trying to override it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to