StephanEwen commented on a change in pull request #13920:
URL: https://github.com/apache/flink/pull/13920#discussion_r520532289
##########
File path:
flink-core/src/main/java/org/apache/flink/api/common/eventtime/WatermarkOutputMultiplexer.java
##########
@@ -136,6 +136,13 @@ public void onPeriodicEmit() {
updateCombinedWatermark();
}
+ /**
+ * Get the combined watermark of all WatermarkOutputs.
+ */
+ public long getCombinedWatermark() {
Review comment:
This here seems unnecessary, I cannot find where it is being used. Can
we revert this change?
##########
File path:
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/SourceOperator.java
##########
@@ -120,6 +125,10 @@
* but we currently need to instantiate this lazily, because the metric
groups exist only later. */
private TimestampsAndWatermarks<OUT> eventTimeLogic;
+ /** The metric group is initialized lazily at runtime. */
+ @VisibleForTesting
+ protected transient SourceMetricGroup sourceMetricGroup;
Review comment:
This is transient when all other fields are not. I think it makes it
confusing for code readers.
The class is serializable (as an artifact from earlier times), but it is
never serialized, because it is created via an operator factory (which is
serializable).
##########
File path:
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/operators/source/TestingSourceOperator.java
##########
@@ -86,6 +87,7 @@ public TestingSourceOperator(
this.parallelism = parallelism;
this.metrics =
UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
this.readerCreated = false;
+ this.sourceMetricGroup = new TestingSourceMetricGroup();
Review comment:
What do you think about having a testing constructor in the
`SourceOperator` that accepts a metric group, rather making a parent field
public and mutating it from here?
##########
File path:
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/SourceOperator.java
##########
@@ -120,6 +125,10 @@
* but we currently need to instantiate this lazily, because the metric
groups exist only later. */
private TimestampsAndWatermarks<OUT> eventTimeLogic;
+ /** The metric group is initialized lazily at runtime. */
+ @VisibleForTesting
+ protected transient SourceMetricGroup sourceMetricGroup;
Review comment:
Minor comment: It is slightly nicer to not make the field visible for
testing, but have a getter that is visible for testing. Field visibility allows
for mutation.
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/SourceMetricGroupImpl.java
##########
@@ -0,0 +1,74 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+package org.apache.flink.runtime.metrics.groups;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.connector.source.metrics.SourceMetricGroup;
+import org.apache.flink.metrics.Counter;
+import org.apache.flink.util.clock.SystemClock;
+
+import java.util.function.Supplier;
+
+/**
+ * A metric group that adds source specific metrics to the SourceOperator.
+ * It adds Source specific metrics to the OperatorMetricsGroup.
+ */
+public class SourceMetricGroupImpl extends
ProxyMetricGroup<OperatorMetricGroup> implements SourceMetricGroup {
+ private final Counter numRecordsInErrorsCounter;
+ private final Counter numBytesIn;
+ private final Supplier<Long> currentWatermarkSupplier;
+
+ public SourceMetricGroupImpl(
+ OperatorMetricGroup parentMetricGroup,
Review comment:
Maybe we can rename this to `operatorMetricGroup` or so, because it is
the same metric group, just extended via the proxy. Whenever I read "parent" in
the code below, I thought this was the actual parent (the TaskMetricGroup) and
though we register the metrics to the wrong group.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]