Skip to content

Commit

Permalink
refactor: Modify the internal abort interface to adapt the hadoop-3.3…
Browse files Browse the repository at this point in the history
….4+, fixes #97
  • Loading branch information
yuyang733 committed Jan 13, 2023
1 parent 4bcd877 commit 4b3d184
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 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.2.1</version>
<version>8.2.2</version>
<packaging>jar</packaging>

<name>Apache Hadoop Tencent Cloud COS Support</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void resumeForWrite() throws IOException {
}
} catch (Exception e) {
LOG.error("Failed to resume for writing. Abort it.", e);
super.abort();
super.doAbort();
throw new IOException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public synchronized void close() throws IOException {
}

@Override
public synchronized void abort() throws IOException {
public synchronized void doAbort() throws IOException {
if (this.closed) {
return;
}
Expand Down Expand Up @@ -652,7 +652,7 @@ protected void complete() throws IOException {
PartETagList = this.partETags;
}
if (null == PartETagList) {
throw new IOException("failed to multipart upload to cos, abort it.");
throw new IOException("failed to multipart upload to cos, doAbort it.");
}

// notice sometimes complete result may be null
Expand All @@ -673,7 +673,7 @@ protected void complete() throws IOException {
protected void abort() throws IOException {
LOG.info("Aborting the MPU [{}].", this.getUploadId());
if (this.isCompleted() || this.isAborted()) {
throw new IOException(String.format("fail to abort the MPU [%s]. "
throw new IOException(String.format("fail to doAbort the MPU [%s]. "
+ "It has been completed or aborted.", this.getUploadId()));
}
nativeStore.abortMultipartUpload(cosKey, this.uploadId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public boolean seekToNewSource(long pos) throws IOException {
}

@Override
public void abort() {
this.seekableOutputStream.abort();
public void doAbort() {
this.seekableOutputStream.doAbort();
}

@Override
Expand Down Expand Up @@ -170,9 +170,9 @@ public synchronized boolean seekToNewSource(long l) throws IOException {
}

@Override
public synchronized void abort() {
public synchronized void doAbort() {
if (this.closed) {
// 已经关闭了,无需额外 abort
// 已经关闭了,无需额外 doAbort
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ public PartETag uploadPartCopy(String uploadId, String srcKey, String destKey,
}

public void abortMultipartUpload(String key, String uploadId) throws IOException {
LOG.info("Ready to abort the multipart upload. cos key: {}, upload id: {}.", key, uploadId);
LOG.info("Ready to doAbort the multipart upload. cos key: {}, upload id: {}.", key, uploadId);

try {
AbortMultipartUploadRequest abortMultipartUploadRequest =
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/hadoop/fs/cosn/Abortable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import java.io.IOException;

public interface Abortable {
void abort() throws IOException;
void doAbort() throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,10 @@ private void releaseRemoteParts() {
LOG.info("Begin to release remote parts for the cos key [{}]. upload id: {}.",
cosKey, this.uploadId);
try {
// abort 掉远程块,就相当于清理掉云端的 parts 了。
// doAbort 掉远程块,就相当于清理掉云端的 parts 了。
nativeStore.abortMultipartUpload(cosKey, this.uploadId);
} catch (IOException e) {
// 如果 abort 发生异常,则原先的 partCopy 块就残留在云端了。不影响当前使用,只需要用户手动去存储桶清理一下即可。
// 如果 doAbort 发生异常,则原先的 partCopy 块就残留在云端了。不影响当前使用,只需要用户手动去存储桶清理一下即可。
LOG.warn("Abort the MPU [{}] for the cos key [{}].", this.uploadId, cosKey, e);
}
}
Expand Down

0 comments on commit 4b3d184

Please sign in to comment.