我正在尝试从 7 台机器上传大量文件。在每台机器中,我运行 6 个线程来上传到 S3 。当我从一台机器上运行上传时,它工作正常,但当我在 7 台机器上运行时,它开始失败。
我在其余机器上遇到以下错误。
错误 - AmazonClientException com.amazonaws.SdkClientException:无法执行 HTTP 请求:等待来自池的连接超时
我上传到 S3 的小文件总数 = 1659328
每个线程中的记录数 = 276554
那么我必须关闭 TransferManager 吗?如果是的话我应该如何关闭它?我的应用程序是多线程的。当我调用tm.shutdownNow();时其他线程将无法使用它。
这是我要上传到 S3 的代码。
AWSCredentials credential = new ProfileCredentialsProvider("skjfffkjg-Prod-ServiceUser").getCredentials();
AmazonS3Client s3Client = (AmazonS3Client) AmazonS3ClientBuilder.standard().withRegion("us-east-1")
.withCredentials(new AWSStaticCredentialsProvider(credential)).withForceGlobalBucketAccessEnabled(true)
.build();
s3Client.getClientConfiguration().setMaxConnections(100);
Run Code Online (Sandbox Code Playgroud)
上传到S3方法
public void uploadToToS3() {
_logger.info("Number of record to be processed in current thread: : " + records.size());
TransferManager tm = new TransferManager(s3Client);
MultipleFileUpload upload = tm.uploadFileList(bucketName, "", new File(fileLocation), records);
if (upload.isDone() == …Run Code Online (Sandbox Code Playgroud)