Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ private void updateHeartbeat(String instantTime) throws HoodieHeartbeatException
heartbeat.setLastHeartbeatTime(newHeartbeatTime);
heartbeat.setNumHeartbeats(heartbeat.getNumHeartbeats() + 1);
} catch (IOException io) {
Boolean isHeartbeatStopped = instantToHeartbeatMap.get(instantTime).isHeartbeatStopped;
if (isHeartbeatStopped) {
LOG.warn(String.format("update heart beat failed, because the instant time %s was stopped ? : %s", instantTime, isHeartbeatStopped));
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to write a test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nsivabalan
It is difficult that the asynchronous heartbeat Timer task thread sends a request to update the heartbeat file to hdfs when the write client stops the heartbeat.
I can only write a similar unit test as follows. Do you have any suggestions?

@Test
  public void testUpdateStoppedHeartbeat() {

    HoodieHeartbeatClient hoodieHeartbeatClient =

        new HoodieHeartbeatClient(metaClient.getFs(), metaClient.getBasePath(), heartBeatInterval, numTolerableMisses);

    hoodieHeartbeatClient.start(instantTime1);

    hoodieHeartbeatClient.stopHeartbeatTimers();

    assertDoesNotThrow(() -> hoodieHeartbeatClient.updateHeartbeat(instantTime1));
  }

throw new HoodieHeartbeatException("Unable to generate heartbeat for instant " + instantTime, io);
}
}
Expand Down