danny0405 commented on code in PR #13766:
URL: https://github.com/apache/hudi/pull/13766#discussion_r2299561715


##########
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()))
 {

Review Comment:
   what is the background of this, is it enough to just reset the timeline on 
remote fs view initialization? if we can assume the timeline among all the 
executors are consistent, it should be okay, otherwise the following-up reuests 
would still trigger regresh of the remote fs view to be with the latest 
timeline.



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