Skip to content

Commit 0da987d

Browse files
authored
Merge branch 'feature/master/s3mpu' into olapplin/fix-subscriber-dowloader
2 parents 7855c6e + dd3eb20 commit 0da987d

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

test/s3-benchmarks/src/main/java/software/amazon/awssdk/s3benchmarks/BenchmarkRunner.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ public static void main(String... args) throws org.apache.commons.cli.ParseExcep
140140
benchmark = new JavaS3ClientCopyBenchmark(config);
141141
break;
142142
}
143-
throw new UnsupportedOperationException("Java based s3 client benchmark only support upload and copy");
143+
if (operation == TransferManagerOperation.DOWNLOAD) {
144+
benchmark = new JavaS3ClientDownloadBenchmark(config);
145+
break;
146+
}
147+
throw new UnsupportedOperationException();
144148
default:
145149
throw new UnsupportedOperationException();
146150
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.s3benchmarks;
17+
18+
import java.io.File;
19+
import java.util.List;
20+
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
21+
import software.amazon.awssdk.utils.Logger;
22+
23+
public class JavaS3ClientDownloadBenchmark extends BaseJavaS3ClientBenchmark {
24+
private static final Logger log = Logger.loggerFor(JavaS3ClientDownloadBenchmark.class);
25+
private final String filePath;
26+
27+
public JavaS3ClientDownloadBenchmark(TransferManagerBenchmarkConfig config) {
28+
super(config);
29+
this.filePath = config.filePath();
30+
}
31+
32+
@Override
33+
protected void sendOneRequest(List<Double> latencies) throws Exception {
34+
Double latency;
35+
if (filePath == null) {
36+
log.info(() -> "Starting download to memory");
37+
latency = runWithTime(s3AsyncClient.getObject(
38+
req -> req.key(key).bucket(bucket), AsyncResponseTransformer.toBytes()
39+
)::join).latency();
40+
} else {
41+
log.info(() -> "Starting download to file");
42+
latency = runWithTime(s3AsyncClient.getObject(
43+
req -> req.key(key).bucket(bucket), new File(filePath).toPath()
44+
)::join).latency();
45+
}
46+
latencies.add(latency);
47+
}
48+
49+
@Override
50+
protected long contentLength() throws Exception {
51+
return s3Client.headObject(b -> b.bucket(bucket).key(key)).contentLength();
52+
}
53+
}

0 commit comments

Comments
 (0)