Skip to content

Commit e39cb25

Browse files
committed
Adding the max_upload_size to the bulk put request. Also added the option to the WriteJobOptions so it can be set when using the bulk put helper function
1 parent 0fa05d9 commit e39cb25

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/BulkPutRequest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@
2424
import java.util.List;
2525

2626
public class BulkPutRequest extends BulkRequest {
27+
28+
private static final String MAX_UPLOAD_SIZE_IN_BYTES = "100000000000";
29+
public static final int MIN_UPLOAD_SIZE_IN_BYTES = 10485760;
30+
2731
public BulkPutRequest(final String bucket, final List<Ds3Object> objects) throws XmlProcessingException {
2832
super(bucket, objects);
29-
getQueryParams().put("operation", "start_bulk_put");
33+
this.getQueryParams().put("operation", "start_bulk_put");
3034
}
3135

3236
@Override
@@ -35,6 +39,21 @@ public BulkPutRequest withPriority(final Priority priority) {
3539
return this;
3640
}
3741

42+
/**
43+
* Sets the chunk size for this job.
44+
* @param size The chunk size in bytes. If the value passed in is less than MIN_UPLOAD_SIZE_IN_BYTES, then
45+
* the default size will be used.
46+
*/
47+
public BulkPutRequest withMaxUploadSize(final int size) {
48+
if (size > MIN_UPLOAD_SIZE_IN_BYTES) {
49+
this.getQueryParams().put("max_upload_size", Long.toString(size));
50+
}
51+
else {
52+
this.getQueryParams().put("max_upload_size", MAX_UPLOAD_SIZE_IN_BYTES);
53+
}
54+
return this;
55+
}
56+
3857
@Override
3958
public BulkPutRequest withWriteOptimization(final WriteOptimization writeOptimization) {
4059
super.withWriteOptimization(writeOptimization);

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/Ds3ClientHelpersImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ private Ds3ClientHelpers.Job innerStartWriteJob(final String bucket,
6969
throws SignatureException, IOException, XmlProcessingException {
7070
final BulkPutResponse prime = this.client.bulkPut(new BulkPutRequest(bucket, Lists.newArrayList(objectsToWrite))
7171
.withPriority(options.getPriority())
72-
.withWriteOptimization(options.getWriteOptimization()));
72+
.withWriteOptimization(options.getWriteOptimization())
73+
.withMaxUploadSize(options.getMaxUploadSize()));
7374
return new WriteJobImpl(this.client, prime.getResult());
7475
}
7576

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/options/WriteJobOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,27 @@
2121
public class WriteJobOptions {
2222
private Priority priority;
2323
private WriteOptimization writeOptimization;
24+
private int maxUploadSize;
2425

2526
private WriteJobOptions() {
2627
this.priority = null;
2728
this.writeOptimization = null;
29+
this.maxUploadSize = 0;
2830
}
2931

3032
public static WriteJobOptions create() {
3133
return new WriteJobOptions();
3234
}
3335

36+
public WriteJobOptions withMaxUploadSize(final int maxUploadSize) {
37+
this.maxUploadSize = maxUploadSize;
38+
return this;
39+
}
40+
41+
public int getMaxUploadSize() {
42+
return this.maxUploadSize;
43+
}
44+
3445
public WriteJobOptions withWriteOptimization(final WriteOptimization writeOptimization) {
3546
this.writeOptimization = writeOptimization;
3647
return this;

0 commit comments

Comments
 (0)