Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Apr 29, 2024
1 parent 8c2946d commit 2c89979
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 33 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-storage/tree/
| Upload Kms Encrypted Object | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/object/UploadKmsEncryptedObject.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/object/UploadKmsEncryptedObject.java) |
| Upload Object | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/object/UploadObject.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/object/UploadObject.java) |
| Upload Object From Memory | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/object/UploadObjectFromMemory.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/object/UploadObjectFromMemory.java) |
| Allow Divide And Conquer Download | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/transfermanager/AllowDivideAndConquerDownload.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/transfermanager/AllowDivideAndConquerDownload.java) |
| Allow Parallel Composite Upload | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/transfermanager/AllowParallelCompositeUpload.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/transfermanager/AllowParallelCompositeUpload.java) |
| Download Bucket | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/transfermanager/DownloadBucket.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/transfermanager/DownloadBucket.java) |
| Download Many | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/transfermanager/DownloadMany.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/transfermanager/DownloadMany.java) |
| Upload Directory | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/transfermanager/UploadDirectory.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/transfermanager/UploadDirectory.java) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@
import com.google.cloud.storage.transfermanager.TransferManagerConfig;
import java.nio.file.Path;
import java.util.List;

class AllowDivideAndConquerDownload {

public static void divideAndConquerDownloadAllowed(List<BlobInfo> blobs,
String bucketName, Path destinationDirectory) {
TransferManager transferManager = TransferManagerConfig.newBuilder()
.setAllowDivideAndConquer(true)
.build()
.getService();
ParallelDownloadConfig parallelDownloadConfig = ParallelDownloadConfig.newBuilder()
.setBucketName(bucketName)
.setDownloadDirectory(destinationDirectory)
.build();
List<DownloadResult> results = transferManager
.downloadBlobs(blobs, parallelDownloadConfig)
.getDownloadResults();
public static void divideAndConquerDownloadAllowed(
List<BlobInfo> blobs, String bucketName, Path destinationDirectory) {
TransferManager transferManager =
TransferManagerConfig.newBuilder().setAllowDivideAndConquer(true).build().getService();
ParallelDownloadConfig parallelDownloadConfig =
ParallelDownloadConfig.newBuilder()
.setBucketName(bucketName)
.setDownloadDirectory(destinationDirectory)
.build();
List<DownloadResult> results =
transferManager.downloadBlobs(blobs, parallelDownloadConfig).getDownloadResults();

for (DownloadResult result : results) {
System.out.println("Download of " + result.getInput().getName()
+ " completed with status "
+ result.getStatus());
System.out.println(
"Download of "
+ result.getInput().getName()
+ " completed with status "
+ result.getStatus());
}

}
}
// [END storage_transfer_manager_download_chunks_concurrently]
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ class AllowParallelCompositeUpload {

public static void parallelCompositeUploadAllowed(String bucketName, List<Path> files)
throws IOException {
TransferManager transferManager = TransferManagerConfig
.newBuilder()
.setAllowDivideAndConquer(true)
.build()
.getService();
TransferManager transferManager =
TransferManagerConfig.newBuilder().setAllowDivideAndConquer(true).build().getService();
ParallelUploadConfig parallelUploadConfig =
ParallelUploadConfig.newBuilder().setBucketName(bucketName).build();
List<UploadResult> results =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,12 @@
import com.google.cloud.storage.testing.RemoteStorageHelper;
import com.google.cloud.testing.junit4.StdOutCaptureRule;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -125,16 +118,16 @@ public void downloadFiles() {
@Test
public void uploadAllowPCU() throws IOException {
File tmpFile = tmpDirectory.newFile("fileDirUpload.txt");
AllowParallelCompositeUpload
.parallelCompositeUploadAllowed(BUCKET, Collections.singletonList(tmpFile.toPath()));
AllowParallelCompositeUpload.parallelCompositeUploadAllowed(
BUCKET, Collections.singletonList(tmpFile.toPath()));
String snippetOutput = stdOutCaptureRule.getCapturedOutputAsUtf8String();
assertThat(snippetOutput.contains("fileDirUpload.txt")).isTrue();
}

@Test
public void downloadAllowDivideAndConquer() {
AllowDivideAndConquerDownload
.divideAndConquerDownloadAllowed(blobs, BUCKET,tmp.getRoot().toPath());
AllowDivideAndConquerDownload.divideAndConquerDownloadAllowed(
blobs, BUCKET, tmp.getRoot().toPath());
String snippetOutput = stdOutCaptureRule.getCapturedOutputAsUtf8String();
assertThat(snippetOutput.contains("blob1")).isTrue();
assertThat(snippetOutput.contains("blob2")).isTrue();
Expand Down

0 comments on commit 2c89979

Please sign in to comment.