pnowojski commented on a change in pull request #16990: URL: https://github.com/apache/flink/pull/16990#discussion_r696349341
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/SourceListener.java ########## @@ -0,0 +1,48 @@ +/* + * 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.Internal; + +/** + * Listens to changes inside the source. This is currently only used as an abstraction for {@link + * InternalSourceReaderMetricGroup}. + * + * <p>Please be cautious to add more implementations of this interface to production code as it's + * performance-sensitive. Ideally, we only have one implementation that can be inlined. + */ +@Internal +public interface SourceListener { Review comment: You are introducing this interface only for the sake of creating test implementation, and then commenting that it shouldn't be extended. Do we really need to do that? Can not we have just a final class tracking last emitted timestamp and watermark? I can see a second reason, a bit cleaner code. With this interface you don't need to pass whole `InternalSourceReaderMetricGroup` to the outputs. However... both of those issues seems to me a problem of using inheritance instead of composition in the `InternalSourceReaderMetricGroup implements SourceListener`. Wouldn't it solve both of those problems if you introduced `public final class SourceListener` and inject it as a parameter to `InternalSourceReaderMetricGroup` and both `SourceOutputWithWatermarks` and `TimestampsOnlyOutput`? This would also render `NoopSourceListener` unnecessary, as instantiating production class would be just as easy. `public final class` wouldn't optimise anything BUT it would provide a compile error and force someone to look at the code and maybe notice this javadoc if someone would violate this . And we would be sure that there is no problem with `NoopSourceListener` leaking to to class loader (for example in benchmarks which are including test dependencies). -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org