You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/12/21 16:34:14 UTC

[GitHub] [flink] XComp commented on a diff in pull request #21467: [FLINK-30301][tests] Increase heartbeat timeout in TaskExecutorTest to prevent unrelated failures

XComp commented on code in PR #21467:
URL: https://github.com/apache/flink/pull/21467#discussion_r1054523544


##########
flink-runtime/src/main/java/org/apache/flink/runtime/heartbeat/HeartbeatManagerSenderImpl.java:
##########
@@ -56,7 +56,7 @@
                 new HeartbeatMonitorImpl.Factory<>());
     }
 
-    HeartbeatManagerSenderImpl(
+    public HeartbeatManagerSenderImpl(

Review Comment:
   ```suggestion
       HeartbeatManagerSenderImpl(
   ```
   This change doesn't seem to be necessary.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/heartbeat/NoOpHeartbeatServices.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.heartbeat;
+
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.util.concurrent.ScheduledExecutor;
+
+import org.slf4j.Logger;
+
+/** {@link HeartbeatServices} implementation which does nothing. */
+public class NoOpHeartbeatServices implements HeartbeatServices {

Review Comment:
   What's the reason to put this class into the production code rather than the test code? Is it because the `NoOpHeartbeatManager` is production code? The `NOpHeartbeatServices` are only used within the test classes. Couldn't we change its scope to test utility class? WDYT?



##########
flink-runtime/src/main/java/org/apache/flink/runtime/heartbeat/HeartbeatServices.java:
##########
@@ -100,37 +62,31 @@ public <I, O> HeartbeatManager<I, O> createHeartbeatManager(
      * @param <O> Type of the outgoing payload
      * @return A new HeartbeatManager instance which actively sends heartbeats
      */
-    public <I, O> HeartbeatManager<I, O> createHeartbeatManagerSender(
+    <I, O> HeartbeatManager<I, O> createHeartbeatManagerSender(
             ResourceID resourceId,
             HeartbeatListener<I, O> heartbeatListener,
             ScheduledExecutor mainThreadExecutor,
-            Logger log) {
-
-        return new HeartbeatManagerSenderImpl<>(
-                heartbeatInterval,
-                heartbeatTimeout,
-                failedRpcRequestsUntilUnreachable,
-                resourceId,
-                heartbeatListener,
-                mainThreadExecutor,
-                log);
-    }
+            Logger log);
 
     /**
      * Creates an HeartbeatServices instance from a {@link Configuration}.
      *
      * @param configuration Configuration to be used for the HeartbeatServices creation
      * @return An HeartbeatServices instance created from the given configuration
      */
-    public static HeartbeatServices fromConfiguration(Configuration configuration) {
+    static HeartbeatServices fromConfiguration(Configuration configuration) {

Review Comment:
   Shouldn't we move this factory method into `HeartbeatServicesImpl` as well to keep the factory method close to the class and not the interface?



##########
flink-runtime/src/main/java/org/apache/flink/runtime/heartbeat/HeartbeatManagerSenderImpl.java:
##########
@@ -37,7 +37,7 @@
 
     private final long heartbeatPeriod;
 
-    HeartbeatManagerSenderImpl(
+    public HeartbeatManagerSenderImpl(

Review Comment:
   I'm wondering whether it would be more reasonable to move `RecordingHeartbeatServices` into `org.apache.flink.runtime.heartbeat` instead of keeping it in `org.apache.flink.runtime.taskexecutor`. This way we wouldn't have to expose the constructors and keep everything around the heartbeat in a single package. I understand that this was already like that beforehand. But I'm curious what you think.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/heartbeat/HeartbeatServices.java:
##########
@@ -100,37 +62,31 @@ public <I, O> HeartbeatManager<I, O> createHeartbeatManager(
      * @param <O> Type of the outgoing payload
      * @return A new HeartbeatManager instance which actively sends heartbeats
      */
-    public <I, O> HeartbeatManager<I, O> createHeartbeatManagerSender(
+    <I, O> HeartbeatManager<I, O> createHeartbeatManagerSender(
             ResourceID resourceId,
             HeartbeatListener<I, O> heartbeatListener,
             ScheduledExecutor mainThreadExecutor,
-            Logger log) {
-
-        return new HeartbeatManagerSenderImpl<>(
-                heartbeatInterval,
-                heartbeatTimeout,
-                failedRpcRequestsUntilUnreachable,
-                resourceId,
-                heartbeatListener,
-                mainThreadExecutor,
-                log);
-    }
+            Logger log);
 
     /**
      * Creates an HeartbeatServices instance from a {@link Configuration}.
      *
      * @param configuration Configuration to be used for the HeartbeatServices creation
      * @return An HeartbeatServices instance created from the given configuration
      */
-    public static HeartbeatServices fromConfiguration(Configuration configuration) {
+    static HeartbeatServices fromConfiguration(Configuration configuration) {
         long heartbeatInterval = configuration.getLong(HeartbeatManagerOptions.HEARTBEAT_INTERVAL);
 
         long heartbeatTimeout = configuration.getLong(HeartbeatManagerOptions.HEARTBEAT_TIMEOUT);
 
         int failedRpcRequestsUntilUnreachable =
                 configuration.get(HeartbeatManagerOptions.HEARTBEAT_RPC_FAILURE_THRESHOLD);
 
-        return new HeartbeatServices(
+        return new HeartbeatServicesImpl(
                 heartbeatInterval, heartbeatTimeout, failedRpcRequestsUntilUnreachable);
     }
+
+    static HeartbeatServices noOp() {

Review Comment:
   That's kind of related to my previous comment: We could remove that if we decide to move the `NoOpheartbeatServices` into the test code, I guess.



-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org