Skip to content

Commit ff5dcee

Browse files
authored
Merge pull request #44 from vintmd/mpu-retry
add the retry when complete mpu error code in body but status code is…
2 parents 920f07b + 2434ad5 commit ff5dcee

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.qcloud.cos</groupId>
88
<artifactId>hadoop-cos</artifactId>
9-
<version>8.0.4</version>
9+
<version>8.0.5</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Apache Hadoop Tencent Qcloud COS Support</name>
@@ -41,7 +41,7 @@
4141
<maven.compiler.source>1.7</maven.compiler.source>
4242
<maven.compiler.target>1.7</maven.compiler.target>
4343
<hadoop.version>3.3.0</hadoop.version>
44-
<cos_api.version>5.6.68</cos_api.version>
44+
<cos_api.version>5.6.69</cos_api.version>
4545
<google.guava.version>24.1.1-jre</google.guava.version>
4646
<commons_lang3.version>3.1</commons_lang3.version>
4747
<junit.version>4.8</junit.version>

src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@InterfaceStability.Unstable
1313
public class CosNConfigKeys extends CommonConfigurationKeys {
1414
public static final String USER_AGENT = "fs.cosn.user.agent";
15-
public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.0.4";
15+
public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.0.5";
1616

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

src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java

+20
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,26 @@ private <X> Object callCOSClientWithRetry(X request) throws CosServiceException,
13741374
LOG.error(errMsg, cse);
13751375
throw new IOException(errMsg);
13761376
}
1377+
} else if (request instanceof CompleteMultipartUploadRequest && statusCode / 100 ==2
1378+
&& errorCode != null && !errorCode.isEmpty()) {
1379+
// complete mpu error code might be in body when status code is 200
1380+
// double check to head object only works in big data job case which key is not same.
1381+
String key = ((CompleteMultipartUploadRequest) request).getKey();
1382+
FileMetadata fileMetadata = this.queryObjectMetadata(key);
1383+
if (null != fileMetadata) {
1384+
// if file exist direct return.
1385+
LOG.info("complete mpu error in body, error code {}, but key {} already exist, length {}",
1386+
errorCode, key, fileMetadata.getLength());
1387+
return new CompleteMultipartUploadResult();
1388+
}
1389+
// here same like the copy request not setting the interval sleep for now
1390+
if (retryIndex <= this.maxRetryTimes) {
1391+
LOG.info(errMsg, cse);
1392+
++retryIndex;
1393+
} else {
1394+
LOG.error(errMsg, cse);
1395+
throw new IOException(errMsg);
1396+
}
13771397
} else if (statusCode / 100 == 5) {
13781398
if (retryIndex <= this.maxRetryTimes) {
13791399
LOG.info(errMsg, cse);

0 commit comments

Comments
 (0)