voonhous commented on code in PR #13147:
URL: https://github.com/apache/hudi/pull/13147#discussion_r3401791168
##########
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;
Review Comment:
Good catch. `getInstantDetails` no longer collapses failures into a
`null`/200 response:
- A malformed `state` or an unsupported `action` now returns 400
(`BadRequestResponse`).
- Any other read/deserialization failure is logged at WARN and surfaced as a
500 (`HoodieException`), matching the RFC's error-handling spec.
The caller can now tell a bad request from a server error. Also normalized
this file's import order, which was failing checkstyle.
--
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]