the-other-tim-brown commented on code in PR #10122:
URL: https://github.com/apache/hudi/pull/10122#discussion_r1399812787


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/embedded/EmbeddedTimelineService.java:
##########
@@ -146,19 +196,65 @@ public FileSystemViewManager getViewManager() {
     return viewManager;
   }
 
-  public boolean canReuseFor(String basePath) {
-    return this.server != null
-        && this.viewManager != null
-        && this.basePath.equals(basePath);
+  /**
+   * Adds a new base path to the set that are managed by this instance.
+   * @param basePath the new base path to add
+   */
+  private void addBasePath(String basePath) {
+    basePaths.add(basePath);
+  }
+
+  private boolean canReuseFor(HoodieWriteConfig newWriteConfig, String 
newHostAddr) {
+    if (server == null || viewManager == null) {
+      return false; // service is not running
+    }
+    if (basePaths.contains(newWriteConfig.getBasePath())) {
+      return true; // already running for this base path
+    }
+    if (newHostAddr != null && !newHostAddr.equals(this.hostAddr)) {
+      return false; // different host address
+    }
+    if (writeConfig.getMarkersType() != newWriteConfig.getMarkersType()) {
+      return false; // different marker type
+    }
+    return 
metadataConfigsAreEquivalent(writeConfig.getMetadataConfig().getProps(), 
newWriteConfig.getMetadataConfig().getProps());
+  }
+
+  private boolean metadataConfigsAreEquivalent(Properties properties1, 
Properties properties2) {
+    Set<Object> metadataConfigs = new HashSet<>(properties1.keySet());
+    metadataConfigs.addAll(properties2.keySet());
+    return metadataConfigs.stream()
+        .filter(key -> ((String) 
key).startsWith(HoodieMetadataConfig.METADATA_PREFIX))
+        .allMatch(key -> {
+          String value1 = properties1.getProperty((String) key, "");
+          String value2 = properties2.getProperty((String) key, "");
+          return value1.equals(value2);
+        });
+
   }
 
-  public void stop() {
-    if (null != server) {
+  /**
+   * Stops the embedded timeline service for the given base path. If a 
timeline service is managing multiple tables, it will only be shutdown once all 
tables have been stopped.
+   * @param basePath For the table to stop the service for
+   */
+  public void stopForBasePath(String basePath) {

Review Comment:
   I don't think the implementation needs to be reflected in the method name. 
We should focus on what the caller's intention is



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