voonhous commented on code in PR #13147:
URL: https://github.com/apache/hudi/pull/13147#discussion_r3401806705
##########
hudi-timeline-service/src/main/java/org/apache/hudi/timeline/service/handlers/TimelineHandler.java:
##########
@@ -46,4 +61,151 @@ public List<InstantDTO> getLastInstant(String basePath) {
public TimelineDTO getTimeline(String basePath) {
return
TimelineDTO.fromTimeline(viewManager.getFileSystemView(basePath).getTimeline());
}
+
+ public org.apache.hudi.common.table.timeline.dto.v2.TimelineDTO
getTimelineV2(String basePath) {
+ return
org.apache.hudi.common.table.timeline.dto.v2.TimelineDTO.fromTimeline(viewManager.getFileSystemView(basePath).getTimeline());
+ }
+
+ public Object getInstantDetails(String basePath, String requestedTime,
String action, String state)
+ throws IOException {
+ HoodieTimeline hoodieTimeline =
viewManager.getFileSystemView(basePath).getTimeline();
+ try {
+ HoodieInstant requestedInstant = new HoodieInstant(
+ HoodieInstant.State.valueOf(state), action, requestedTime,
+ InstantComparatorV1.REQUESTED_TIME_BASED_COMPARATOR);
+
+ Object result;
+ switch (requestedInstant.getAction()) {
+ case HoodieTimeline.COMMIT_ACTION:
+ case HoodieTimeline.DELTA_COMMIT_ACTION:
+ result = hoodieTimeline.readCommitMetadata(requestedInstant);
+ break;
+ case HoodieTimeline.CLEAN_ACTION:
+ result = requestedInstant.isCompleted()
+ ? hoodieTimeline.readCleanMetadata(requestedInstant)
+ : hoodieTimeline.readCleanerPlan(requestedInstant);
+ break;
+ case HoodieTimeline.ROLLBACK_ACTION:
+ result = requestedInstant.isCompleted()
+ ? hoodieTimeline.readRollbackMetadata(requestedInstant)
+ : hoodieTimeline.readRollbackPlan(requestedInstant);
+ break;
+ case HoodieTimeline.RESTORE_ACTION:
+ result = requestedInstant.isCompleted()
+ ? hoodieTimeline.readRestoreMetadata(requestedInstant)
+ : hoodieTimeline.readRestorePlan(requestedInstant);
+ break;
+ case HoodieTimeline.SAVEPOINT_ACTION:
+ result = hoodieTimeline.readSavepointMetadata(requestedInstant);
+ break;
+ case HoodieTimeline.COMPACTION_ACTION:
+ case HoodieTimeline.LOG_COMPACTION_ACTION:
+ result = requestedInstant.isCompleted()
+ ? hoodieTimeline.readCommitMetadata(requestedInstant)
+ : hoodieTimeline.readCompactionPlan(requestedInstant);
+ break;
+ case HoodieTimeline.REPLACE_COMMIT_ACTION:
+ case HoodieTimeline.CLUSTERING_ACTION:
+ result = requestedInstant.isCompleted()
+ ? hoodieTimeline.readCommitMetadata(requestedInstant)
+ : hoodieTimeline.readRequestedReplaceMetadata(requestedInstant);
+ break;
+ case HoodieTimeline.INDEXING_ACTION:
+ result = requestedInstant.isCompleted()
+ ? hoodieTimeline.readCommitMetadata(requestedInstant)
+ : hoodieTimeline.readIndexPlan(requestedInstant);
+ break;
+ default:
+ result = null;
+ break;
+ }
+
+ // Avro-generated objects (SpecificRecordBase) cannot be serialized by
+ // RequestHandler's ObjectMapper+AfterburnerModule due to module access
+ // restrictions on Avro's internal Schema classes. Convert to plain Maps
+ // using JsonUtils which accesses fields directly, bypassing getSchema().
+ if (result instanceof SpecificRecordBase) {
+ return JsonUtils.getObjectMapper().convertValue(result, Map.class);
Review Comment:
Good point, and it lines up with the RFC. Added a per-basepath
`ConcurrentHashMap<String, HoodieTableMetaClient>` cache in `TimelineHandler`
with a `getOrCreateMetaClient(basePath)` helper. `getTableConfig` and
`getSchemaHistory` now reuse the cached metaClient instead of rebuilding one
per request, so the hoodie.properties/timeline load is paid once per basepath.
(`getInstantDetails` reads through the already-cached `FileSystemView` from
`FileSystemViewManager`, so it does not build a metaClient at all.) Timeline
freshness is unaffected since `getSchemaHistory` reloads via
`getActiveTimeline()` on each call.
--
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]