danny0405 commented on code in PR #13766:
URL: https://github.com/apache/hudi/pull/13766#discussion_r2299518709
##########
hudi-timeline-service/src/main/java/org/apache/hudi/timeline/service/handlers/TimelineHandler.java:
##########
@@ -46,4 +53,33 @@ public List<InstantDTO> getLastInstant(String basePath) {
public TimelineDTO getTimeline(String basePath) {
return
TimelineDTO.fromTimeline(viewManager.getFileSystemView(basePath).getTimeline());
}
+
+ public String getTimelineHash(String basePath) {
+ return
viewManager.getFileSystemView(basePath).getTimeline().getTimelineHash();
+ }
+
+ public boolean initializeTimeline(String basePath, TimelineDTO timelineDTO) {
+ HoodieTableMetaClient metaClient = HoodieTableMetaClient.builder()
+ .setConf(conf)
+ .setBasePath(basePath)
+ .build();
+ HoodieTimeline hoodieTimeline = TimelineDTO.toTimeline(timelineDTO,
metaClient);
+ // Check if we already have the right view.
+ if (viewManager.doesFileSystemViewExists(basePath)
+ && hoodieTimeline.getTimelineHash().equals(
+
viewManager.getFileSystemView(basePath).getTimeline().getTimelineHash())) {
+ LOG.debug("Timeline hashes match returning view for basePath {}",
basePath);
+ return true;
+ }
+ // Lock on the viewManager.
+ synchronized (viewManager) {
+ SyncableFileSystemView viewInServer =
viewManager.getFileSystemView(metaClient, hoodieTimeline);
+ if
(!hoodieTimeline.getTimelineHash().equals(viewInServer.getTimeline().getTimelineHash()))
{
+ LOG.info("Clearing and Re-creating view as timeline hashes don't match
for basePath {}", basePath);
+ viewManager.clearFileSystemView(basePath);
+ viewManager.getFileSystemView(metaClient, hoodieTimeline);
Review Comment:
looks like we want to init the fs view with just the specific timeline from
client, in `ViewHandler#handle`, we already have the ability to refresh the fs
view the local and remove timeline mismatch, should we just fix that instead of
add a new request here?(to ensure the consistency for each request).
--
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]