[ 
https://issues.apache.org/jira/browse/FLINK-4449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15853988#comment-15853988
 ] 

ASF GitHub Bot commented on FLINK-4449:
---------------------------------------

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

    https://github.com/apache/flink/pull/2791#discussion_r99581239
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/HeartbeatService.java
 ---
    @@ -0,0 +1,131 @@
    +/*
    + * 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.resourcemanager;
    +
    +import org.apache.flink.runtime.clusterframework.types.ResourceID;
    +import org.apache.flink.runtime.heartbeat.HeartbeatListener;
    +import org.apache.flink.runtime.heartbeat.HeartbeatManagerSenderImpl;
    +import org.apache.flink.runtime.heartbeat.HeartbeatTarget;
    +import org.apache.flink.runtime.taskexecutor.TaskExecutorGateway;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.concurrent.Executor;
    +import java.util.concurrent.Executors;
    +import java.util.concurrent.ScheduledExecutorService;
    +import java.util.concurrent.TimeUnit;
    +
    +/**
    + * Service which is responsible for heartbeat communication with 
TaskExecutor.
    + */
    +public class HeartbeatService {
    +
    +   private static final Logger LOG = 
LoggerFactory.getLogger(HeartbeatService.class);
    +
    +   private final HeartbeatManagerSenderImpl<Void, Void> 
taskExecutorHeartbeatManager;
    +
    +   private HeartbeatListener<Void, Void> taskExecutorHeartbeatListener;
    +
    +   /** Resource ID of the ResourceManager */
    +   private final ResourceID resourceManagerIdentify;
    +
    +   private final ScheduledExecutorService scheduledExecutorService;
    +
    +   public HeartbeatService(ResourceManagerConfiguration 
resourceManagerConfiguration, Executor executor) {
    +           this.resourceManagerIdentify = ResourceID.generate();
    +           this.scheduledExecutorService = 
Executors.newScheduledThreadPool(16);
    +           this.taskExecutorHeartbeatManager = new 
HeartbeatManagerSenderImpl<>(resourceManagerConfiguration.getHeartbeatInterval().toMilliseconds(),
    +                   
resourceManagerConfiguration.getTimeout().toMilliseconds(), 
resourceManagerIdentify, executor, scheduledExecutorService, LOG);
    +   }
    +
    +   /**
    +    * Starts the service with the given heartbeat listener
    +    *
    +    * @param taskExecutorHeartbeatListener heartbeat listener to listener 
for heartbeat actions with TaskExecutor
    +    */
    +   public void start(HeartbeatListener<Void, Void> 
taskExecutorHeartbeatListener) {
    +           
this.taskExecutorHeartbeatManager.start(taskExecutorHeartbeatListener);
    +   }
    +
    +   /**
    +    * Stops the service
    +    *
    +    * @throws Exception
    +    */
    +   public void stop() throws Exception {
    +           try {
    +                   scheduledExecutorService.shutdown();
    +                   while 
(!scheduledExecutorService.awaitTermination(5000L, TimeUnit.MILLISECONDS)) {
    +                           // break util scheduleExecutorService terminates
    +                   }
    +           } finally {
    +                   this.taskExecutorHeartbeatManager.stop();
    +           }
    +   }
    +
    +   /**
    +    * Adds a TaskExecutor to monitor
    +    *
    +    * @param resourceID          ResourceId of the taskExecutor to monitor
    +    * @param taskExecutorGateway the taskExecutor to monitor
    +    */
    +   public void monitorTaskExecutor(ResourceID resourceID, final 
TaskExecutorGateway taskExecutorGateway) {
    +
    +           this.taskExecutorHeartbeatManager.monitorTarget(resourceID, new 
HeartbeatTarget<Void>() {
    +
    +                           @Override
    +                           public void sendHeartbeat(ResourceID 
resourceID, Void payload) {
    +                                   throw new 
UnsupportedOperationException("the sendHeartbeat is not supported here!");
    --- End diff --
    
    Why not?


> Heartbeat Manager integration with TaskExecutor
> -----------------------------------------------
>
>                 Key: FLINK-4449
>                 URL: https://issues.apache.org/jira/browse/FLINK-4449
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Cluster Management
>            Reporter: zhangjing
>            Assignee: zhangjing
>
> ResourceManager need a heartbeat manager to monitor the connections with all 
> registered TaskExecutor.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to