zhangyue19921010 commented on code in PR #6133: URL: https://github.com/apache/hudi/pull/6133#discussion_r1064928603
########## hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/marker/SimpleDirectMarkerBasedEarlyConflictDetectionStrategy.java: ########## @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hudi.table.marker; + +import org.apache.hudi.common.conflict.detection.HoodieDirectMarkerBasedEarlyConflictDetectionStrategy; +import org.apache.hudi.common.fs.HoodieWrapperFileSystem; +import org.apache.hudi.common.table.timeline.HoodieActiveTimeline; +import org.apache.hudi.common.table.timeline.HoodieInstant; +import org.apache.hudi.common.util.MarkerUtils; +import org.apache.hudi.config.HoodieWriteConfig; +import org.apache.hudi.exception.HoodieEarlyConflictDetectionException; +import org.apache.hudi.exception.HoodieIOException; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +import java.io.IOException; +import java.util.ConcurrentModificationException; +import java.util.HashSet; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * This strategy is used for direct marker writers, trying to do early conflict detection. + * It will use fileSystem api like list and exist directly to check if there is any marker file conflict. + */ +public class SimpleDirectMarkerBasedEarlyConflictDetectionStrategy extends HoodieDirectMarkerBasedEarlyConflictDetectionStrategy { + + private static final Logger LOG = LogManager.getLogger(SimpleDirectMarkerBasedEarlyConflictDetectionStrategy.class); + + public SimpleDirectMarkerBasedEarlyConflictDetectionStrategy(String basePath, HoodieWrapperFileSystem fs, String partitionPath, String fileId, String instantTime, Review Comment: simplify the args. Removed basePath, checkCommitConflict, maxAllowableHeartbeatIntervalInMs,and completedCommitInstants. We can get all these info from config or timeline. ########## hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/marker/WriteMarkers.java: ########## @@ -52,16 +58,47 @@ public WriteMarkers(String basePath, String markerFolderPath, String instantTime this.instantTime = instantTime; } + public Option<Path> create(String partitionPath, String dataFileName, IOType type) { + return create(partitionPath, dataFileName, type, Option.empty()); + } + /** * Creates a marker without checking if the marker already exists. * * @param partitionPath partition path in the table * @param dataFileName data file name * @param type write IO type + * @param handler could be empty * @return the marker path */ - public Option<Path> create(String partitionPath, String dataFileName, IOType type) { - return create(partitionPath, dataFileName, type, false); + public Option<Path> create(String partitionPath, String dataFileName, IOType type, Option<HoodieWriteHandle> handler) { 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]
