16
16
17
17
package com .google .cloud .storage .transfermanager ;
18
18
19
+ import static com .google .common .base .Preconditions .checkNotNull ;
20
+
21
+ import com .google .cloud .storage .ParallelCompositeUploadBlobWriteSessionConfig .PartNamingStrategy ;
19
22
import com .google .cloud .storage .StorageOptions ;
20
23
import com .google .common .base .MoreObjects ;
21
24
import java .util .Objects ;
@@ -31,18 +34,22 @@ public final class TransferManagerConfig {
31
34
private final boolean allowDivideAndConquerDownload ;
32
35
private final boolean allowParallelCompositeUpload ;
33
36
37
+ private final PartNamingStrategy partNamingStrategy ;
38
+
34
39
private final StorageOptions storageOptions ;
35
40
36
41
TransferManagerConfig (
37
42
int maxWorkers ,
38
43
int perWorkerBufferSize ,
39
44
boolean allowDivideAndConquerDownload ,
40
45
boolean allowParallelCompositeUpload ,
46
+ PartNamingStrategy partNamingStrategy ,
41
47
StorageOptions storageOptions ) {
42
48
this .maxWorkers = maxWorkers ;
43
49
this .perWorkerBufferSize = perWorkerBufferSize ;
44
50
this .allowDivideAndConquerDownload = allowDivideAndConquerDownload ;
45
51
this .allowParallelCompositeUpload = allowParallelCompositeUpload ;
52
+ this .partNamingStrategy = partNamingStrategy ;
46
53
this .storageOptions = storageOptions ;
47
54
}
48
55
@@ -101,6 +108,15 @@ public StorageOptions getStorageOptions() {
101
108
return storageOptions ;
102
109
}
103
110
111
+ /**
112
+ * Part Naming Strategy to be used during Parallel Composite Uploads
113
+ *
114
+ * @see Builder#setParallelCompositeUploadPartNamingStrategy(PartNamingStrategy)
115
+ */
116
+ public PartNamingStrategy getParallelCompositeUploadPartNamingStrategy () {
117
+ return partNamingStrategy ;
118
+ }
119
+
104
120
/** The service object for {@link TransferManager} */
105
121
public TransferManager getService () {
106
122
return new TransferManagerImpl (this , DefaultQos .of (this ));
@@ -169,13 +185,15 @@ public static class Builder {
169
185
private boolean allowParallelCompositeUpload ;
170
186
171
187
private StorageOptions storageOptions ;
188
+ private PartNamingStrategy partNamingStrategy ;
172
189
173
190
private Builder () {
174
191
this .perWorkerBufferSize = 16 * 1024 * 1024 ;
175
192
this .maxWorkers = 2 * Runtime .getRuntime ().availableProcessors ();
176
193
this .allowDivideAndConquerDownload = false ;
177
194
this .allowParallelCompositeUpload = false ;
178
195
this .storageOptions = StorageOptions .getDefaultInstance ();
196
+ this .partNamingStrategy = PartNamingStrategy .noPrefix ();
179
197
}
180
198
181
199
/**
@@ -246,6 +264,21 @@ public Builder setStorageOptions(StorageOptions storageOptions) {
246
264
return this ;
247
265
}
248
266
267
+ /**
268
+ * Part Naming Strategy that Transfer Manager will use during Parallel Composite Upload
269
+ *
270
+ * <p><i>Default Value:</i> {@link PartNamingStrategy#noPrefix()}
271
+ *
272
+ * @return the instance of Builder with the value for PartNamingStrategy modified.
273
+ * @see TransferManagerConfig#getParallelCompositeUploadPartNamingStrategy()
274
+ */
275
+ public Builder setParallelCompositeUploadPartNamingStrategy (
276
+ PartNamingStrategy partNamingStrategy ) {
277
+ checkNotNull (partNamingStrategy );
278
+ this .partNamingStrategy = partNamingStrategy ;
279
+ return this ;
280
+ }
281
+
249
282
/**
250
283
* Creates a TransferManagerConfig object.
251
284
*
@@ -257,6 +290,7 @@ public TransferManagerConfig build() {
257
290
perWorkerBufferSize ,
258
291
allowDivideAndConquerDownload ,
259
292
allowParallelCompositeUpload ,
293
+ partNamingStrategy ,
260
294
storageOptions );
261
295
}
262
296
}
0 commit comments