1616
1717package com .google .cloud .storage .transfermanager ;
1818
19+ import static com .google .common .base .Preconditions .checkNotNull ;
20+
21+ import com .google .cloud .storage .ParallelCompositeUploadBlobWriteSessionConfig .PartNamingStrategy ;
1922import com .google .cloud .storage .StorageOptions ;
2023import com .google .common .base .MoreObjects ;
2124import java .util .Objects ;
@@ -31,18 +34,22 @@ public final class TransferManagerConfig {
3134 private final boolean allowDivideAndConquerDownload ;
3235 private final boolean allowParallelCompositeUpload ;
3336
37+ private final PartNamingStrategy partNamingStrategy ;
38+
3439 private final StorageOptions storageOptions ;
3540
3641 TransferManagerConfig (
3742 int maxWorkers ,
3843 int perWorkerBufferSize ,
3944 boolean allowDivideAndConquerDownload ,
4045 boolean allowParallelCompositeUpload ,
46+ PartNamingStrategy partNamingStrategy ,
4147 StorageOptions storageOptions ) {
4248 this .maxWorkers = maxWorkers ;
4349 this .perWorkerBufferSize = perWorkerBufferSize ;
4450 this .allowDivideAndConquerDownload = allowDivideAndConquerDownload ;
4551 this .allowParallelCompositeUpload = allowParallelCompositeUpload ;
52+ this .partNamingStrategy = partNamingStrategy ;
4653 this .storageOptions = storageOptions ;
4754 }
4855
@@ -101,6 +108,15 @@ public StorageOptions getStorageOptions() {
101108 return storageOptions ;
102109 }
103110
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+
104120 /** The service object for {@link TransferManager} */
105121 public TransferManager getService () {
106122 return new TransferManagerImpl (this , DefaultQos .of (this ));
@@ -169,13 +185,15 @@ public static class Builder {
169185 private boolean allowParallelCompositeUpload ;
170186
171187 private StorageOptions storageOptions ;
188+ private PartNamingStrategy partNamingStrategy ;
172189
173190 private Builder () {
174191 this .perWorkerBufferSize = 16 * 1024 * 1024 ;
175192 this .maxWorkers = 2 * Runtime .getRuntime ().availableProcessors ();
176193 this .allowDivideAndConquerDownload = false ;
177194 this .allowParallelCompositeUpload = false ;
178195 this .storageOptions = StorageOptions .getDefaultInstance ();
196+ this .partNamingStrategy = PartNamingStrategy .noPrefix ();
179197 }
180198
181199 /**
@@ -246,6 +264,21 @@ public Builder setStorageOptions(StorageOptions storageOptions) {
246264 return this ;
247265 }
248266
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+
249282 /**
250283 * Creates a TransferManagerConfig object.
251284 *
@@ -257,6 +290,7 @@ public TransferManagerConfig build() {
257290 perWorkerBufferSize ,
258291 allowDivideAndConquerDownload ,
259292 allowParallelCompositeUpload ,
293+ partNamingStrategy ,
260294 storageOptions );
261295 }
262296 }
0 commit comments