-
Notifications
You must be signed in to change notification settings - Fork 20
Replace Minio dependency with a service #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b49ee15
Add S3ClientService wrapper for Minio
manics 12174cb
Register S3ClientService
manics 3a59777
S3Handle uses S3ClientService
manics 9f2b5dc
s3: use "initialize" spelling
manics 62b65bd
s3: cleanups, more javadocs
manics 4bfb0e3
S3: Use slf4j to print disabled test warning
manics 0341243
S3: Add @throws to silence javadocs warnings
manics File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * #%L | ||
| * S3 client service | ||
| * %% | ||
| * Copyright (C) 2019 Open Microscopy Environment: | ||
| * - Board of Regents of the University of Wisconsin-Madison | ||
| * - Glencoe Software, Inc. | ||
| * - University of Dundee | ||
| * %% | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
| * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| * #L% | ||
| */ | ||
|
|
||
| package loci.common.services; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
|
|
||
| /** | ||
| * An S3 client | ||
| */ | ||
| public interface S3ClientService extends Service { | ||
|
|
||
| /** | ||
| * Initialise the S3 client | ||
| * @param server servername | ||
| * @param port port | ||
| * @param accessKey access key | ||
| * @param secretKey secret key | ||
| * @param appName user agent application name | ||
| * @param appVersion user agent application version | ||
| * @throws S3ClientServiceException if an S3 error occurred | ||
| */ | ||
| void initialize(String server, int port, String accessKey, String secretKey, | ||
| String appName, String appVersion) | ||
|
manics marked this conversation as resolved.
|
||
| throws S3ClientServiceException; | ||
|
|
||
| /** | ||
| * Check whether a bucket exists | ||
| * @param bucket Bucket name | ||
| * @return true if bucket exists | ||
| * @throws S3ClientServiceException if an S3 error occurred | ||
| * @throws IOException if an S3 error occurred | ||
| */ | ||
| boolean bucketExists(String bucket) throws S3ClientServiceException, IOException; | ||
|
|
||
| /** | ||
| * Stat the object | ||
| * @param bucket Bucket name | ||
| * @param object Object path | ||
| * @return S3ClientStat object | ||
| * @throws S3ClientServiceException if an S3 error occurred | ||
| * @throws IOException if an S3 error occurred | ||
| */ | ||
| S3ClientStat statObject(String bucket, String object) throws S3ClientServiceException, IOException; | ||
|
|
||
| /** | ||
| * Read an object | ||
| * @param bucket Bucket name | ||
| * @param object Object path | ||
| * @param offset Start reading at this offset | ||
| * @return InputStream to the object | ||
| * @throws S3ClientServiceException if an S3 error occurred | ||
| * @throws IOException if an S3 error occurred | ||
| */ | ||
| InputStream getObject(String bucket, String object, long offset) throws S3ClientServiceException, IOException; | ||
|
|
||
| /** | ||
| * Download an object | ||
| * @param bucket Bucket name | ||
| * @param object Object path | ||
| * @param filename Destination file | ||
| * @throws S3ClientServiceException if an S3 error occurred | ||
| * @throws IOException if an S3 error occurred | ||
| */ | ||
| void getObject(String bucket, String object, String filename) throws S3ClientServiceException, IOException; | ||
|
|
||
| } | ||
67 changes: 67 additions & 0 deletions
67
src/main/java/loci/common/services/S3ClientServiceException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * #%L | ||
| * S3 client stat object | ||
| * %% | ||
| * Copyright (C) 2019 Open Microscopy Environment: | ||
| * - Board of Regents of the University of Wisconsin-Madison | ||
| * - Glencoe Software, Inc. | ||
| * - University of Dundee | ||
| * %% | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
| * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| * #L% | ||
| */ | ||
|
|
||
| package loci.common.services; | ||
|
|
||
| /** | ||
| * Exception thrown when internal error specific to the S3 client is raised | ||
| */ | ||
| public class S3ClientServiceException extends ServiceException | ||
| { | ||
| /** | ||
| * Constructor. | ||
| * @param message Error message. | ||
| */ | ||
| public S3ClientServiceException(String message) | ||
| { | ||
| super(message); | ||
| } | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * @param message Error message. | ||
| * @param cause Upstream exception. | ||
| */ | ||
| public S3ClientServiceException(String message, Throwable cause) | ||
| { | ||
| super(message, cause); | ||
| } | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * @param cause Upstream exception. | ||
| */ | ||
| public S3ClientServiceException(Throwable cause) | ||
| { | ||
| super(cause); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.