This mechanism is designed for uploading file in parallel and asynchronously:
- improve the performance of uploading file to OSS server. Firstly, this mechanism splits result to multiple small blocks and upload them in parallel. Then, getting result and uploading blocks are asynchronous.
- avoid buffering too large result into local disk. To cite an extreme example, there is a task which will output 100GB or even larger, we may need to output this 100GB to local disk and then upload it. Sometimes, it is inefficient and limited to disk space.
This patch reuse SemaphoredDelegatingExecutor as executor service and depends on
Attached asynchronous_file_uploading.pdf illustrated the difference between previous AliyunOSSOutputStream and AliyunOSSBlockOutputStream, i.e. this asynchronous multi-part based uploading mechanism.
1. AliyunOSSOutputStream: we need to output the whole result to local disk before we can upload it to OSS. This will poses two problems：
- if the output file is too large, it will run out of the local disk.
- if the output file is too large, task will wait long time to upload result to OSS before finish, wasting much compute resource.
2. AliyunOSSBlockOutputStream: we cut the task output into small blocks, i.e. some small local file, and each block will be packaged into a uploading task. These tasks will be submitted into SemaphoredDelegatingExecutor. SemaphoredDelegatingExecutor will upload this blocks in parallel, this will improve performance greatly.
3. Each task will retry 3 times to upload block to Aliyun OSS. If one of those tasks failed, the whole file uploading will failed, and we will abort current uploading.