jt2594838 commented on a change in pull request #1512:
URL: https://github.com/apache/incubator-iotdb/pull/1512#discussion_r457010104



##########
File path: 
cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncDataHeartbeatClient.java
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.iotdb.cluster.client.async;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.iotdb.cluster.config.ClusterDescriptor;
+import org.apache.iotdb.cluster.rpc.thrift.Node;
+import org.apache.iotdb.cluster.rpc.thrift.RaftService;
+import org.apache.iotdb.cluster.rpc.thrift.TSDataService.AsyncClient;
+import org.apache.iotdb.cluster.server.RaftServer;
+import org.apache.iotdb.cluster.utils.ClusterUtils;
+import org.apache.thrift.async.TAsyncClientManager;
+import org.apache.thrift.protocol.TProtocolFactory;
+import org.apache.thrift.transport.TNonblockingSocket;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Notice: Because a client will be returned to a pool immediately after a 
successful request, you
+ * should not cache it anywhere else or there may be conflicts.
+ */
+public class AsyncDataHeartbeatClient extends AsyncClient {

Review comment:
       I think maybe you can just extend AsyncDataClient and override the 
factory and constructor so there will be fewer duplicated codes.
   
   Or maybe you can extract heartbeat-related methods in RaftService into a new 
service, so it can be better decoupled.

##########
File path: 
cluster/src/main/java/org/apache/iotdb/cluster/utils/ClusterUtils.java
##########
@@ -48,11 +50,24 @@
 
   public static final long START_UP_CHECK_TIME_INTERVAL = 5; // second
 
+  /**
+   * the data group member's heartbeat offset relative to the {@link 
ClusterConfig#getLocalDataPort()},
+   * which means the dataHeartbeatPort = getLocalDataPort() + 
DATA_HEARTBEAT_OFFSET.
+   */
+  public static final int DATA_HEARTBEAT_OFFSET = 1;

Review comment:
       How about using "DATA_HEARTBEAT_PORT_OFFSET" so it would be more clear 
what the port is for?




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to