Skip to content

Commit fd49232

Browse files
committed
report heartbeat
1 parent bf1adc3 commit fd49232

7 files changed

Lines changed: 66 additions & 3 deletions

File tree

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
2727
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
2828
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
29+
import org.apache.iotdb.common.rpc.thrift.TPipeHeartbeatResp;
2930
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
3031
import org.apache.iotdb.common.rpc.thrift.TSStatus;
3132
import org.apache.iotdb.common.rpc.thrift.TSchemaNode;
@@ -2562,6 +2563,23 @@ public TThrottleQuotaResp getThrottleQuota() {
25622563
: new TThrottleQuotaResp(status);
25632564
}
25642565

2566+
@Override
2567+
public TSStatus pushHeartbeat(final int dataNodeId, final TPipeHeartbeatResp resp) {
2568+
final TSStatus status = confirmLeader();
2569+
if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
2570+
return status;
2571+
}
2572+
pipeManager
2573+
.getPipeRuntimeCoordinator()
2574+
.parseHeartbeat(
2575+
dataNodeId,
2576+
resp.getPipeMetaList(),
2577+
resp.getPipeCompletedList(),
2578+
resp.getPipeRemainingEventCountList(),
2579+
resp.getPipeRemainingTimeList());
2580+
return StatusUtils.OK;
2581+
}
2582+
25652583
@Override
25662584
public DataSet registerAINode(TAINodeRegisterReq req) {
25672585
TSStatus status = confirmLeader();

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
2323
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
2424
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
25+
import org.apache.iotdb.common.rpc.thrift.TPipeHeartbeatResp;
2526
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2627
import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
2728
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
@@ -823,4 +824,6 @@ TDataPartitionTableResp getOrCreateDataPartition(
823824

824825
/** Set space quota. */
825826
TSStatus setSpaceQuota(TSetSpaceQuotaReq req);
827+
828+
TSStatus pushHeartbeat(final int dataNodeId, final TPipeHeartbeatResp resp);
826829
}

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
2424
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
2525
import org.apache.iotdb.common.rpc.thrift.TNodeLocations;
26+
import org.apache.iotdb.common.rpc.thrift.TPipeHeartbeatResp;
2627
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2728
import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
2829
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
@@ -1298,4 +1299,9 @@ public TThrottleQuotaResp showThrottleQuota(TShowThrottleReq req) {
12981299
public TThrottleQuotaResp getThrottleQuota() {
12991300
return configManager.getThrottleQuota();
13001301
}
1302+
1303+
@Override
1304+
public TSStatus pushHeartbeat(final int dataNodeId, final TPipeHeartbeatResp resp) {
1305+
return configManager.pushHeartbeat(dataNodeId, resp);
1306+
}
13011307
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/PipeDataNodeTaskAgent.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.apache.iotdb.db.pipe.agent.task;
2121

2222
import org.apache.iotdb.common.rpc.thrift.TPipeHeartbeatResp;
23+
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2324
import org.apache.iotdb.commons.concurrent.IoTThreadFactory;
2425
import org.apache.iotdb.commons.concurrent.ThreadName;
2526
import org.apache.iotdb.commons.concurrent.threadpool.WrappedThreadPoolExecutor;
@@ -55,6 +56,9 @@
5556
import org.apache.iotdb.db.pipe.metric.overview.PipeTsFileToTabletsMetrics;
5657
import org.apache.iotdb.db.pipe.resource.PipeDataNodeResourceManager;
5758
import org.apache.iotdb.db.pipe.resource.memory.PipeMemoryManager;
59+
import org.apache.iotdb.db.protocol.client.ConfigNodeClient;
60+
import org.apache.iotdb.db.protocol.client.ConfigNodeClientManager;
61+
import org.apache.iotdb.db.protocol.client.ConfigNodeInfo;
5862
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeId;
5963
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.pipe.PipeOperateSchemaQueueNode;
6064
import org.apache.iotdb.db.schemaengine.SchemaEngine;
@@ -65,6 +69,7 @@
6569
import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaRespExceptionMessage;
6670
import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameters;
6771
import org.apache.iotdb.pipe.api.exception.PipeException;
72+
import org.apache.iotdb.rpc.TSStatusCode;
6873

6974
import com.google.common.collect.ImmutableMap;
7075
import org.apache.thrift.TException;
@@ -455,7 +460,8 @@ private void collectPipeMetaListInternal(final TDataNodeHeartbeatResp resp) thro
455460
protected void collectPipeMetaListInternal(
456461
final TPipeHeartbeatReq req, final TPipeHeartbeatResp resp) throws TException {
457462
// Do nothing if data node is removing or removed, or request does not need pipe meta list
458-
if (PipeDataNodeAgent.runtime().isShutdown()) {
463+
// If the heartbeat
464+
if (PipeDataNodeAgent.runtime().isShutdown() && req.heartbeatId != Long.MIN_VALUE) {
459465
return;
460466
}
461467
LOGGER.info("Received pipe heartbeat request {} from config node.", req.heartbeatId);
@@ -597,6 +603,28 @@ public void runPipeTasks(
597603

598604
///////////////////////// Shutdown Logic /////////////////////////
599605

606+
public void persistAllProgressIndex() {
607+
persistAllProgressIndexLocally();
608+
persistAllProgressIndex2ConfigNode();
609+
}
610+
611+
public void persistAllProgressIndex2ConfigNode() {
612+
try (final ConfigNodeClient configNodeClient =
613+
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
614+
// Send request to some API server
615+
final TPipeHeartbeatResp resp = new TPipeHeartbeatResp();
616+
collectPipeMetaList(new TPipeHeartbeatReq(Long.MIN_VALUE), resp);
617+
final TSStatus result =
618+
configNodeClient.pushHeartbeat(
619+
IoTDBDescriptor.getInstance().getConfig().getDataNodeId(), resp);
620+
if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != result.getCode()) {
621+
LOGGER.warn("Failed to persist progress index to configNode, status: {}", result);
622+
}
623+
} catch (final Exception e) {
624+
LOGGER.warn(e.getMessage());
625+
}
626+
}
627+
600628
public void persistAllProgressIndexLocally() {
601629
if (!PipeConfig.getInstance().isPipeProgressIndexPersistEnabled()) {
602630
LOGGER.info(

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
2525
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
2626
import org.apache.iotdb.common.rpc.thrift.TNodeLocations;
27+
import org.apache.iotdb.common.rpc.thrift.TPipeHeartbeatResp;
2728
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2829
import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
2930
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
@@ -1271,6 +1272,13 @@ public TThrottleQuotaResp getThrottleQuota() throws TException {
12711272
() -> client.getThrottleQuota(), resp -> !updateConfigNodeLeader(resp.status));
12721273
}
12731274

1275+
@Override
1276+
public TSStatus pushHeartbeat(final int dataNodeId, final TPipeHeartbeatResp resp)
1277+
throws TException {
1278+
return executeRemoteCallWithRetry(
1279+
() -> client.pushHeartbeat(dataNodeId, resp), status -> !updateConfigNodeLeader(status));
1280+
}
1281+
12741282
public static class Factory extends ThriftClientFactory<ConfigRegionId, ConfigNodeClient> {
12751283

12761284
public Factory(

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNodeShutdownHook.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void run() {
111111
}
112112
}
113113
// Persist progress index before shutdown to accurate recovery after restart
114-
PipeDataNodeAgent.task().persistAllProgressIndexLocally();
114+
PipeDataNodeAgent.task().persistAllProgressIndex();
115115

116116
// Shutdown pipe progressIndex background service
117117
PipePeriodicalJobExecutor.shutdownBackgroundService();

iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,6 @@ service IConfigNodeRPCService {
17731773
TThrottleQuotaResp getThrottleQuota()
17741774

17751775
/** Push heartbeat in shutdown */
1776-
common.TSStatus pushHeartbeat(common.TPipeHeartbeatResp resp)
1776+
common.TSStatus pushHeartbeat(i32 dataNodeId, common.TPipeHeartbeatResp resp)
17771777
}
17781778

0 commit comments

Comments
 (0)