Skip to content

Commit

Permalink
mpu 409 retry with head (#58)
Browse files Browse the repository at this point in the history
Co-authored-by: alantong <[email protected]>
  • Loading branch information
vintmd and vintmd authored May 28, 2022
1 parent 3aa7f33 commit 8528a3e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.qcloud.cos</groupId>
<artifactId>hadoop-cos</artifactId>
<version>8.0.7</version>
<version>8.0.8</version>
<packaging>jar</packaging>

<name>Apache Hadoop Tencent Cloud COS Support</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@InterfaceStability.Unstable
public class CosNConfigKeys extends CommonConfigurationKeys {
public static final String USER_AGENT = "fs.cosn.user.agent";
public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.0.7";
public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.0.8";

public static final String TENCENT_EMR_VERSION_KEY = "fs.emr.version";

Expand Down
21 changes: 20 additions & 1 deletion src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,27 @@ public int compare(PartETag o1, PartETag o2) {
partETagList);
completeMultipartUploadRequest.setObjectMetadata(objectMetadata);
return (CompleteMultipartUploadResult) this.callCOSClientWithRetry(completeMultipartUploadRequest);
} catch (CosServiceException cse) {
// 避免并发上传的问题
int statusCode = cse.getStatusCode();
if (statusCode == 409) {
// Check一下这个文件是否已经存在
FileMetadata fileMetadata = this.queryObjectMetadata(key);
if (null == fileMetadata) {
// 如果文件不存在,则需要抛出异常
handleException(cse, key);
}
LOG.warn("Upload the cos key [{}] complete mpu concurrently", key);
} else {
// 其他错误都要抛出来
String errMsg = String.format("Complete the multipart upload failed. " +
"cos service exception, cos key: %s, upload id: %s, " +
"exception: %s", key, uploadId, cse.toString());
handleException(new Exception(errMsg), key);
}
} catch (Exception e) {
String errMsg = String.format("Complete the multipart upload failed. cos key: %s, upload id: %s, " +
String errMsg = String.format("Complete the multipart upload failed. " +
"cos key: %s, upload id: %s, " +
"exception: %s", key, uploadId, e.toString());
handleException(new Exception(errMsg), key);
}
Expand Down

0 comments on commit 8528a3e

Please sign in to comment.