fhan688 commented on code in PR #12466:
URL: https://github.com/apache/hudi/pull/12466#discussion_r1890058114


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -568,6 +569,30 @@ protected void postCommit(HoodieTable table, 
HoodieCommitMetadata metadata, Stri
       // Delete the marker directory for the instant.
       WriteMarkersFactory.get(config.getMarkersType(), table, instantTime)
           .quietDeleteMarkerDir(context, config.getMarkersDeleteParallelism());
+      if (metrics.getClusteringInstantTimerCtx() != null) {
+        long durationInMs = 
metrics.getDurationInMs(metrics.getClusteringInstantTimerCtx().stop());
+        // Compute Metrics
+        Set<String> validActions = 
CollectionUtils.createSet(HoodieMetrics.CLUSTERTING_INSTANT_ACTION);
+        HoodieActiveTimeline activeTimeline = table.getActiveTimeline();
+        HoodieTimeline inflightAndRequested = 
activeTimeline.filterInflightsAndRequested()
+                .filter(instant -> validActions.contains(instant.getAction()));
+        long pendingClusteringInstantCount = 
Long.valueOf(inflightAndRequested.countInstants());
+        long earliestInflightClusteringInstant = 0L;
+        Option<HoodieInstant> firstInstant = 
inflightAndRequested.firstInstant();
+        if (firstInstant.isPresent()) {
+          earliestInflightClusteringInstant = 
Long.valueOf(firstInstant.get().requestedTime());
+        }
+
+        HoodieTimeline completed = activeTimeline.filterCompletedInstants()
+            .filter(instant -> validActions.contains(instant.getAction()));
+        long latestCompletedClusteringInstant = 0L;
+        Option<HoodieInstant> lastInstant = completed.lastInstant();
+        if (lastInstant.isPresent()) {
+          latestCompletedClusteringInstant = 
Long.valueOf(lastInstant.get().requestedTime());
+        }

Review Comment:
   Thanks for advising, updated according to all above comments.



-- 
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]

Reply via email to