skywalker0618 commented on code in PR #20735:
URL: https://github.com/apache/hudi/pull/20735#discussion_r4647958991
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/enumerator/HoodieContinuousSplitEnumerator.java:
##########
@@ -90,22 +132,80 @@ public HoodieSplitEnumeratorState snapshotState(long
checkpointId) throws Except
return new HoodieSplitEnumeratorState(splitProvider.state(),
position.get().getIssuedInstant(), position.get().getIssuedOffset());
}
- private HoodieContinuousSplitBatch discoverSplits() {
+ @Override
+ void onSplitsFinished(Collection<String> finishedSplitIds) {
+ if (lagMetrics != null) {
+ lagMetrics.finishSplits(finishedSplitIds);
+ }
+ }
+
+ @Override
+ void onSplitsAddedBack(List<HoodieSourceSplit> splits) {
+ if (lagMetrics != null) {
+ lagMetrics.addSplits(getSplitLagInfo(splits));
+ }
+ }
+
+ /**
+ * Returns the discovered splits, with their lag info and the completion
times of the commits left to
+ * discover, which are null when the metrics are disabled or failed to be
resolved.
+ */
+ private DiscoveryResult discoverSplits() {
+ String issuedOffset = position.get().getIssuedOffset().orElse(null);
int pendingSplitNumber = splitProvider.pendingSplitCount();
if (pendingSplitNumber > scanContext.getMaxPendingSplits()) {
log.info(
"Pause split discovery as the assigner already has too many pending
splits: {}",
pendingSplitNumber);
- return HoodieContinuousSplitBatch.EMPTY;
+ return new DiscoveryResult(HoodieContinuousSplitBatch.EMPTY,
Collections.emptyMap(), getUndiscoveredCommits(issuedOffset, true));
+ }
+ HoodieContinuousSplitBatch batch =
splitDiscover.discoverSplits(issuedOffset);
+ String nextOffset = StringUtils.isNullOrEmpty(batch.getOffset()) ?
issuedOffset : batch.getOffset();
+ return new DiscoveryResult(batch, resolveLagInfo(batch.getSplits()),
getUndiscoveredCommits(nextOffset, false));
Review Comment:
Great suggestion, moved the lag info to async
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]