zhangyue19921010 commented on code in PR #6133:
URL: https://github.com/apache/hudi/pull/6133#discussion_r1028232202


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieLockConfig.java:
##########
@@ -189,6 +190,33 @@ public class HoodieLockConfig extends HoodieConfig {
       .withDocumentation("Lock provider class name, this should be subclass of 
"
           + "org.apache.hudi.client.transaction.ConflictResolutionStrategy");
 
+  // Pluggable strategies to use when early conflict detection
+  public static final ConfigProperty<String> 
EARLY_CONFLICT_DETECTION_STRATEGY_CLASS_NAME = ConfigProperty
+      .key(LOCK_PREFIX + "early.conflict.detection.strategy")
+      
.defaultValue(AsyncTimelineMarkerEarlyConflictDetectionStrategy.class.getName())
+      .sinceVersion("0.12.0")
+      .withDocumentation("Early conflict detection class name, this should be 
subclass of "
+          + 
"org.apache.hudi.common.conflict.detection.HoodieEarlyConflictDetectionStrategy");
+
+  public static final ConfigProperty<Boolean> EARLY_CONFLICT_DETECTION_ENABLE 
= ConfigProperty
+      .key(LOCK_PREFIX + "early.conflict.detection.enable")
+      .defaultValue(false)
+      .sinceVersion("0.12.0")

Review Comment:
   changed.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieLockConfig.java:
##########
@@ -189,6 +190,33 @@ public class HoodieLockConfig extends HoodieConfig {
       .withDocumentation("Lock provider class name, this should be subclass of 
"
           + "org.apache.hudi.client.transaction.ConflictResolutionStrategy");
 
+  // Pluggable strategies to use when early conflict detection
+  public static final ConfigProperty<String> 
EARLY_CONFLICT_DETECTION_STRATEGY_CLASS_NAME = ConfigProperty
+      .key(LOCK_PREFIX + "early.conflict.detection.strategy")
+      
.defaultValue(AsyncTimelineMarkerEarlyConflictDetectionStrategy.class.getName())

Review Comment:
   changed.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieWriteHandle.java:
##########
@@ -187,8 +194,54 @@ protected Path makeNewFilePath(String partitionPath, 
String fileName) {
    * @param partitionPath Partition path
    */
   protected void createMarkerFile(String partitionPath, String dataFileName) {
-    WriteMarkersFactory.get(config.getMarkersType(), hoodieTable, instantTime)
-        .create(partitionPath, dataFileName, getIOType());
+    WriteMarkers writeMarkers = 
WriteMarkersFactory.get(config.getMarkersType(), hoodieTable, instantTime);
+    // do early conflict detection before create markers.
+    if (config.getWriteConcurrencyMode().supportsOptimisticConcurrencyControl()
+        && config.isEarlyConflictDetectionEnable()) {
+      HoodieEarlyConflictDetectionStrategy earlyConflictDetectionStrategy = 
config.getEarlyConflictDetectionStrategy();
+      if (earlyConflictDetectionStrategy instanceof 
HoodieTransactionDirectMarkerBasedEarlyConflictDetectionStrategy) {
+        createMarkerWithTransaction(earlyConflictDetectionStrategy, 
writeMarkers, partitionPath, dataFileName);
+      } else {
+        createMarkerWithEarlyConflictDetection(earlyConflictDetectionStrategy, 
writeMarkers, partitionPath, dataFileName);
+      }
+    } else {
+      // create marker directly
+      writeMarkers.create(partitionPath, dataFileName, getIOType());
+    }
+  }
+
+  private Option<Path> 
createMarkerWithEarlyConflictDetection(HoodieEarlyConflictDetectionStrategy 
resolutionStrategy,
+                                                              WriteMarkers 
writeMarkers,
+                                                              String 
partitionPath,
+                                                              String 
dataFileName) {
+    Set<HoodieInstant> completedCommitInstants = 
hoodieTable.getMetaClient().getActiveTimeline()

Review Comment:
   changed.



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