Skip to content

Commit e718db4

Browse files
committed
1 parent 693f49f commit e718db4

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/main/java/de/taimos/pipeline/aws/S3DownloadStep.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ public class S3DownloadStep extends AbstractS3Step {
5252
private final String bucket;
5353
private String path = "";
5454
private boolean force = false;
55+
private boolean disableParallelDownloads = false;
5556

5657
@DataBoundConstructor
57-
public S3DownloadStep(String file, String bucket, boolean pathStyleAccessEnabled, boolean payloadSigningEnabled) {
58+
public S3DownloadStep(String file, String bucket, boolean pathStyleAccessEnabled, boolean payloadSigningEnabled, boolean disableParallelDownloads) {
5859
super(pathStyleAccessEnabled, payloadSigningEnabled);
5960
this.file = file;
6061
this.bucket = bucket;
62+
this.disableParallelDownloads = disableParallelDownloads;
6163
}
6264

6365
public String getFile() {
@@ -76,6 +78,10 @@ public boolean isForce() {
7678
return this.force;
7779
}
7880

81+
public boolean isDisableParallelDownloads() {
82+
return this.disableParallelDownloads;
83+
}
84+
7985
@DataBoundSetter
8086
public void setForce(boolean force) {
8187
this.force = force;
@@ -86,6 +92,11 @@ public void setPath(String path) {
8692
this.path = path;
8793
}
8894

95+
@DataBoundSetter
96+
public void setDisableParallelDownload(boolean disableParallelDownloads) {
97+
this.disableParallelDownloads = disableParallelDownloads;
98+
}
99+
89100
@Override
90101
public StepExecution start(StepContext context) throws Exception {
91102
return new S3DownloadStep.Execution(this, context);
@@ -130,6 +141,7 @@ public Void run() throws Exception {
130141
final String bucket = this.step.getBucket();
131142
final String path = this.step.getPath();
132143
final boolean force = this.step.isForce();
144+
final boolean disableParallelDownloads = this.step.isDisableParallelDownloads();
133145

134146
Preconditions.checkArgument(bucket != null && !bucket.isEmpty(), "Bucket must not be null or empty");
135147

@@ -146,7 +158,7 @@ public Void run() throws Exception {
146158
throw new RuntimeException("Target exists: " + target.toURI().toString());
147159
}
148160
}
149-
target.act(new RemoteDownloader(Execution.this.step.createS3ClientOptions(), envVars, listener, bucket, path));
161+
target.act(new RemoteDownloader(Execution.this.step.createS3ClientOptions(), envVars, listener, bucket, path, disableParallelDownloads));
150162
listener.getLogger().println("Download complete");
151163
return null;
152164
}
@@ -162,19 +174,22 @@ private static class RemoteDownloader extends MasterToSlaveFileCallable<Void> {
162174
private final TaskListener taskListener;
163175
private final String bucket;
164176
private final String path;
177+
private final Boolean disableParallelDownloads;
165178

166-
RemoteDownloader(S3ClientOptions amazonS3ClientOptions, EnvVars envVars, TaskListener taskListener, String bucket, String path) {
179+
RemoteDownloader(S3ClientOptions amazonS3ClientOptions, EnvVars envVars, TaskListener taskListener, String bucket, String path, Boolean disableParallelDownloads) {
167180
this.amazonS3ClientOptions = amazonS3ClientOptions;
168181
this.envVars = envVars;
169182
this.taskListener = taskListener;
170183
this.bucket = bucket;
171184
this.path = path;
185+
this.disableParallelDownloads = disableParallelDownloads;
172186
}
173187

174188
@Override
175189
public Void invoke(File localFile, VirtualChannel channel) throws IOException, InterruptedException {
176190
TransferManager mgr = TransferManagerBuilder.standard()
177191
.withS3Client(AWSClientFactory.create(this.amazonS3ClientOptions.createAmazonS3ClientBuilder(), this.envVars))
192+
.withDisableParallelDownloads(this.disableParallelDownloads)
178193
.build();
179194

180195
if (this.path == null || this.path.isEmpty() || this.path.endsWith("/")) {

src/test/java/de/taimos/pipeline/aws/S3DownloadStepTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@
2727
public class S3DownloadStepTest {
2828
@Test
2929
public void gettersWorkAsExpected() throws Exception {
30-
S3DownloadStep step = new S3DownloadStep("my-file", "my-bucket", false, false);
30+
S3DownloadStep step = new S3DownloadStep("my-file", "my-bucket", false, false, false);
3131
Assert.assertEquals("my-file", step.getFile());
3232
Assert.assertEquals("my-bucket", step.getBucket());
3333
}
3434

3535
@Test
3636
public void defaultPathIsEmpty() throws Exception {
37-
S3DownloadStep step = new S3DownloadStep("my-file", "my-bucket", false, false);
37+
S3DownloadStep step = new S3DownloadStep("my-file", "my-bucket", false, false, false);
3838
Assert.assertEquals("", step.getPath());
3939
}
4040

4141
@Test
4242
public void defaultForceIsFalse() throws Exception {
43-
S3DownloadStep step = new S3DownloadStep("my-file", "my-bucket", false, false);
43+
S3DownloadStep step = new S3DownloadStep("my-file", "my-bucket", false, false, false);
4444
Assert.assertFalse(step.isForce());
4545
}
4646
}

0 commit comments

Comments
 (0)