diff --git a/pom.xml b/pom.xml index 360aacc8..effd3c0e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.qcloud.cos hadoop-cos - 8.0.7 + 8.0.8 jar Apache Hadoop Tencent Cloud COS Support diff --git a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java index 2d0e3b6f..bb957731 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java +++ b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java @@ -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"; diff --git a/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java b/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java index b588b0d3..ff52c303 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java +++ b/src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java @@ -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); }