Skip to content

Commit 0362e80

Browse files
authored
docs: Javadocs for remainder of Transfer Manager (#2097)
1 parent 63d8ed3 commit 0362e80

File tree

7 files changed

+288
-5
lines changed

7 files changed

+288
-5
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/transfermanager/DownloadJob.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
3030
import org.checkerframework.checker.nullness.qual.NonNull;
3131

32+
/**
33+
* A parallel download job sent to Transfer Manager.
34+
*
35+
* @see Builder
36+
*/
3237
@BetaApi
3338
public final class DownloadJob {
3439

@@ -43,11 +48,23 @@ private DownloadJob(
4348
this.parallelDownloadConfig = parallelDownloadConfig;
4449
}
4550

51+
/**
52+
* The list of {@link DownloadResult DownloadResults} for each download request Transfer Manager
53+
* executed for this job. Note calling this method will block the invoking thread until all
54+
* download requests are complete.
55+
*
56+
* @see Builder#setDownloadResults(List)
57+
*/
4658
@BetaApi
4759
public @NonNull List<DownloadResult> getDownloadResults() {
4860
return ApiExceptions.callAndTranslateApiException(ApiFutures.allAsList(downloadResults));
4961
}
5062

63+
/**
64+
* The {@link ParallelDownloadConfig} used for this DownloadJob.
65+
*
66+
* @see Builder#setParallelDownloadConfig(ParallelDownloadConfig)
67+
*/
5168
@BetaApi
5269
public @NonNull ParallelDownloadConfig getParallelDownloadConfig() {
5370
return parallelDownloadConfig;
@@ -84,6 +101,11 @@ public static Builder newBuilder() {
84101
return new Builder();
85102
}
86103

104+
/**
105+
* Builds an instance of DownloadJob
106+
*
107+
* @see DownloadJob
108+
*/
87109
@BetaApi
88110
public static final class Builder {
89111

@@ -94,19 +116,36 @@ private Builder() {
94116
this.downloadResults = ImmutableList.of();
95117
}
96118

119+
/**
120+
* Sets the results for a DownloadJob being performed by Transfer Manager.
121+
*
122+
* @return the instance of the Builder with DownloadResults modified.
123+
* @see DownloadJob#getDownloadResults()
124+
*/
97125
@BetaApi
98126
public Builder setDownloadResults(@NonNull List<ApiFuture<DownloadResult>> downloadResults) {
99127
this.downloadResults = ImmutableList.copyOf(downloadResults);
100128
return this;
101129
}
102130

131+
/**
132+
* Sets the {@link ParallelDownloadConfig} used for this DownloadJob.
133+
*
134+
* @return the instance of the Builder with ParallelDownloadConfig modified.
135+
* @see DownloadJob#getParallelDownloadConfig()
136+
*/
103137
@BetaApi
104138
public Builder setParallelDownloadConfig(
105139
@NonNull ParallelDownloadConfig parallelDownloadConfig) {
106140
this.parallelDownloadConfig = parallelDownloadConfig;
107141
return this;
108142
}
109143

144+
/**
145+
* Creates a DownloadJob object.
146+
*
147+
* @return {@link DownloadJob}
148+
*/
110149
@BetaApi
111150
public DownloadJob build() {
112151
checkNotNull(downloadResults);

google-cloud-storage/src/main/java/com/google/cloud/storage/transfermanager/DownloadResult.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
2929
import org.checkerframework.checker.nullness.qual.NonNull;
3030

31+
/**
32+
* Result for a single download performed by Transfer Manager.
33+
*
34+
* @see Builder
35+
*/
3136
@BetaApi
3237
public final class DownloadResult {
3338
static final Comparator<DownloadResult> COMPARATOR =
@@ -49,11 +54,22 @@ private DownloadResult(
4954
this.exception = exception;
5055
}
5156

57+
/**
58+
* The {@link BlobInfo} for the object requested for download.
59+
*
60+
* @see Builder#setInput(BlobInfo)
61+
*/
5262
@BetaApi
5363
public @NonNull BlobInfo getInput() {
5464
return input;
5565
}
5666

67+
/**
68+
* The destination on the Filesystem the object has been written to. This field will only be
69+
* populated if the Transfer was a {@link TransferStatus#SUCCESS SUCCESS}.
70+
*
71+
* @see Builder#setOutputDestination(Path)
72+
*/
5773
@BetaApi
5874
public @NonNull Path getOutputDestination() {
5975
checkState(
@@ -63,11 +79,24 @@ private DownloadResult(
6379
return outputDestination;
6480
}
6581

82+
/**
83+
* The status of the download operation.
84+
*
85+
* @see TransferStatus
86+
* @see Builder#setStatus(TransferStatus)
87+
*/
6688
@BetaApi
6789
public @NonNull TransferStatus getStatus() {
6890
return status;
6991
}
7092

93+
/**
94+
* The exception produced by a failed download operation. This field will only be populated if the
95+
* Transfer was not {@link TransferStatus#SUCCESS success}ful or {@link TransferStatus#SKIPPED
96+
* skipped}
97+
*
98+
* @see Builder#setException(Exception)
99+
*/
71100
@BetaApi
72101
public @NonNull Exception getException() {
73102
checkState(
@@ -112,6 +141,11 @@ public static Builder newBuilder(@NonNull BlobInfo blobInfo, @NonNull TransferSt
112141
return new Builder(blobInfo, status);
113142
}
114143

144+
/**
145+
* Builds an instance of DownloadResult
146+
*
147+
* @see DownloadResult
148+
*/
115149
@BetaApi
116150
public static final class Builder {
117151

@@ -125,30 +159,62 @@ private Builder(@NonNull BlobInfo input, @NonNull TransferStatus status) {
125159
this.status = status;
126160
}
127161

162+
/**
163+
* Sets the {@link BlobInfo} for the object request for download. This field is required.
164+
*
165+
* @see DownloadResult#getInput()
166+
* @return the instance of the Builder with the value for input modified.
167+
*/
128168
@BetaApi
129169
public Builder setInput(@NonNull BlobInfo input) {
130170
this.input = input;
131171
return this;
132172
}
133173

174+
/**
175+
* Sets the location on the Filesystem the object has been written to. This field will only be
176+
* populated if the Transfer was {@link TransferStatus#SUCCESS success}ful.
177+
*
178+
* @see DownloadResult#getOutputDestination()
179+
* @return the instance of the Builder with the value for outputDestination modified.
180+
*/
134181
@BetaApi
135182
public Builder setOutputDestination(@NonNull Path outputDestination) {
136183
this.outputDestination = outputDestination;
137184
return this;
138185
}
139186

187+
/**
188+
* Sets the status of the download.This field is required.
189+
*
190+
* @see TransferStatus
191+
* @return the instance of the Builder with the value for status modified.
192+
*/
140193
@BetaApi
141194
public Builder setStatus(@NonNull TransferStatus status) {
142195
this.status = status;
143196
return this;
144197
}
145198

199+
/**
200+
* Sets the Exception produced by a failed download operation. This field will only be populated
201+
* if the Transfer was not {@link TransferStatus#SUCCESS success}ful or {@link
202+
* TransferStatus#SKIPPED skipped}
203+
*
204+
* @see DownloadResult#getException()
205+
* @return the instance of the Builder with the value for exception modified.
206+
*/
146207
@BetaApi
147208
public Builder setException(@NonNull Exception exception) {
148209
this.exception = exception;
149210
return this;
150211
}
151212

213+
/**
214+
* Creates a DownloadResult object.
215+
*
216+
* @return {@link DownloadResult}
217+
*/
152218
@BetaApi
153219
public DownloadResult build() {
154220
checkNotNull(input);

google-cloud-storage/src/main/java/com/google/cloud/storage/transfermanager/TransferManagerConfig.java

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
import com.google.common.base.MoreObjects;
2222
import java.util.Objects;
2323

24+
/**
25+
* Configuration for an instance of {@link TransferManager}
26+
*
27+
* @see Builder
28+
*/
2429
@BetaApi
2530
public final class TransferManagerConfig {
2631
private final int maxWorkers;
@@ -43,13 +48,21 @@ public final class TransferManagerConfig {
4348
this.qos = qos;
4449
}
4550

46-
/** Maximum amount of workers to be allocated to perform work in Transfer Manager */
51+
/**
52+
* Maximum amount of workers to be allocated to perform work in Transfer Manager
53+
*
54+
* @see Builder#setMaxWorkers(int)
55+
*/
4756
@BetaApi
4857
public int getMaxWorkers() {
4958
return maxWorkers;
5059
}
5160

52-
/** Buffer size allowed to each worker */
61+
/**
62+
* Buffer size allowed to each worker
63+
*
64+
* @see Builder#setPerWorkerBufferSize(int)
65+
*/
5366
@BetaApi
5467
public int getPerWorkerBufferSize() {
5568
return perWorkerBufferSize;
@@ -58,18 +71,25 @@ public int getPerWorkerBufferSize() {
5871
/**
5972
* Whether to allow Transfer Manager to perform chunked Uploads/Downloads if it determines
6073
* chunking will be beneficial
74+
*
75+
* @see Builder#setAllowDivideAndConquer(boolean)
6176
*/
6277
@BetaApi
6378
public boolean isAllowDivideAndConquer() {
6479
return allowDivideAndConquer;
6580
}
6681

67-
/** Storage options that Transfer Manager will use to interact with GCS */
82+
/**
83+
* Storage options that Transfer Manager will use to interact with Google Cloud Storage
84+
*
85+
* @see Builder#setStorageOptions(StorageOptions)
86+
*/
6887
@BetaApi
6988
public StorageOptions getStorageOptions() {
7089
return storageOptions;
7190
}
7291

92+
/** The service object for {@link TransferManager} */
7393
@BetaApi
7494
public TransferManager getService() {
7595
return new TransferManagerImpl(this);
@@ -124,6 +144,11 @@ public static Builder newBuilder() {
124144
return new Builder();
125145
}
126146

147+
/**
148+
* Builds an instance of TransferManagerConfig
149+
*
150+
* @see TransferManagerConfig
151+
*/
127152
@BetaApi
128153
public static class Builder {
129154

@@ -142,24 +167,58 @@ private Builder() {
142167
this.qos = DefaultQos.of();
143168
}
144169

170+
/**
171+
* Maximum amount of workers to be allocated to perform work in Transfer Manager
172+
*
173+
* <p><i>Default Value:</i> {@code 2 * }{@link Runtime#getRuntime()}{@code .}{@link
174+
* Runtime#availableProcessors() availableProcessors()}
175+
*
176+
* @return the instance of Builder with the value for maxWorkers modified.
177+
* @see TransferManagerConfig#getMaxWorkers()
178+
*/
145179
@BetaApi
146180
public Builder setMaxWorkers(int maxWorkers) {
147181
this.maxWorkers = maxWorkers;
148182
return this;
149183
}
150184

185+
/**
186+
* Buffer size allowed to each worker
187+
*
188+
* <p><i>Default Value:</i> 16MiB
189+
*
190+
* @return the instance of Builder with the value for maxWorkers modified.
191+
* @see TransferManagerConfig#getPerWorkerBufferSize()
192+
*/
151193
@BetaApi
152194
public Builder setPerWorkerBufferSize(int perWorkerBufferSize) {
153195
this.perWorkerBufferSize = perWorkerBufferSize;
154196
return this;
155197
}
156198

199+
/**
200+
* Whether to allow Transfer Manager to perform chunked Uploads/Downloads if it determines
201+
* chunking will be beneficial
202+
*
203+
* <p><i>Default Value:</i> false
204+
*
205+
* @return the instance of Builder with the value for allowDivideAndConquer modified.
206+
* @see TransferManagerConfig#isAllowDivideAndConquer()
207+
*/
157208
@BetaApi
158209
public Builder setAllowDivideAndConquer(boolean allowDivideAndConquer) {
159210
this.allowDivideAndConquer = allowDivideAndConquer;
160211
return this;
161212
}
162213

214+
/**
215+
* Storage options that Transfer Manager will use to interact with Google Cloud Storage
216+
*
217+
* <p><i>Default Value:</i> {@link StorageOptions#getDefaultInstance()}
218+
*
219+
* @return the instance of Builder with the value for storageOptions modified.
220+
* @see TransferManagerConfig#getStorageOptions()
221+
*/
163222
@BetaApi
164223
public Builder setStorageOptions(StorageOptions storageOptions) {
165224
this.storageOptions = storageOptions;
@@ -172,6 +231,11 @@ Builder setQos(Qos qos) {
172231
return this;
173232
}
174233

234+
/**
235+
* Creates a TransferManagerConfig object.
236+
*
237+
* @return {@link TransferManagerConfig}
238+
*/
175239
@BetaApi
176240
public TransferManagerConfig build() {
177241
return new TransferManagerConfig(

google-cloud-storage/src/main/java/com/google/cloud/storage/transfermanager/TransferManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void close() throws Exception {
7777
}
7878
return UploadJob.newBuilder()
7979
.setParallelUploadConfig(config)
80-
.setUploadResponses(ImmutableList.copyOf(uploadTasks))
80+
.setUploadResults(ImmutableList.copyOf(uploadTasks))
8181
.build();
8282
}
8383

google-cloud-storage/src/main/java/com/google/cloud/storage/transfermanager/TransferStatus.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,23 @@
1919
import com.google.api.core.BetaApi;
2020
import java.util.Comparator;
2121

22+
/** The status of a Upload/Download operation performed by Transfer Manager. */
2223
@BetaApi
2324
public enum TransferStatus {
25+
/** The transfer failed before bytes could be moved. */
2426
@BetaApi
2527
FAILED_TO_START,
28+
/** The transfer failed after bytes could be moved. */
2629
@BetaApi
2730
FAILED_TO_FINISH,
31+
/**
32+
* The transfer failed because the object/file already exists and skipIfExists was set to true.
33+
*
34+
* @see ParallelUploadConfig.Builder#setSkipIfExists(boolean)
35+
*/
2836
@BetaApi
2937
SKIPPED,
38+
/** The transfer was successful. */
3039
@BetaApi
3140
SUCCESS;
3241

0 commit comments

Comments
 (0)