-
Notifications
You must be signed in to change notification settings - Fork 24
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
Adding storeLargeFileFromLocalContentAsync method to B2StorageClient #145
Conversation
This behaves like `storeLargeFileFromLocalContent` but returns a cancellable future which will prevent additional tasks from starting and attempt to cancel in-progress API calls. Addresses #16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so far, i've just written some nitpicks. still letting the overall thing sink in. (and i skimmed the completion stuff.)
core/src/main/java/com/backblaze/b2/client/B2CancellationToken.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/backblaze/b2/client/B2LargeFileStorer.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/backblaze/b2/client/B2LargeFileStorer.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. these seem like good improvements. :)
i'm wondering if we can/should have an example use somewhere -- as a javadoc comment somewhere? in B2Sample? in our README? not sure where.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff! Just a few suggestions on the tests
} | ||
@Test | ||
public void testPassthroughMethods() throws B2Exception, IOException { | ||
cancellableContentSource.getContentLength(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the passthrough tests, it would be stronger to also check the return values/side-effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea thanks!
|
||
@Test(expected = IOException.class) | ||
public void testInputStreamReadCancelled() throws B2Exception, IOException { | ||
final InputStream inputStream = cancellableContentSource.createInputStream(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can tell me if I'm being too annoying, but it might be a stronger test if we set up the ExpectedException
right before we call read()
. Especially since an earlier commit had exceptions getting thrown in both cancel()
and read()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're not being annoying -- its an annoying change but the right one. Thanks for pointing this out.
|
||
@Test | ||
public void testStoreFileAsyncCancelled() throws B2Exception, IOException, ExecutionException, InterruptedException { | ||
final List<B2PartStorer> partStorers = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice test!
* Update CHANGELOG.md to include release 4.0.0 * disable content compression so as not to automatically decompress compressed content (#142) * disable content compression so as not to automatically decompress compressed content in getContent * add more explanation to setContentCompressionEnabled(false) * new comments for setContentCompressionEnabled(false) * bump major version and update CHANGELOG * fix grammar -> by default * adding suffix SNAPSHOT to major version * create B2Json version of ByteArrayOutputStream and throws IOException… (#143) * create B2Json version of ByteArrayOutputStream and throws IOException(Requested array size exceeds maximum limit) * use smaller MAX_ARRAY_SIZE for unit test to avoid OOM error in builds * revisions based on comments from ab, malay * rewrite and rename B2JsonByteArrayOutputStream to B2JsonBoundedByteArrayOutputStream * more revisions for B2JsonBoundedByteArrayOutputStream.java * revisions based on brianb's comments and other discussions * add more comments on the technical context of throwing IOException for B2JsonBoundedByteArrayOutputStream * revised internal implementation of B2JsonBoundedByteArrayOutputStream; add tests for maxCapacity 0, integer overflow; other revision based on comments * remove tests to catch IOException for integer overflow since it causes Travis CI build failure * add index bounds check, fix bug where maxCapacity is not a power of 2 * refactor parameter length for checkCapacity * Adding storeLargeFileFromLocalContentAsync method to B2StorageClient (#145) * Adding storeLargeFileFromLocalContentAsync method to B2StorageClient This behaves like `storeLargeFileFromLocalContent` but returns a cancellable future which will prevent additional tasks from starting and attempt to cancel in-progress API calls. * fix B2LargeFileStorerTest * update Changelog for 5.0.0 release * update version.txt for 5.0.0 release Co-authored-by: Keith Felt <[email protected]> Co-authored-by: keithele <[email protected]> Co-authored-by: mxue-BB <[email protected]> Co-authored-by: malaysf <[email protected]>
This behaves like
storeLargeFileFromLocalContent
but returns a cancellable future which will prevent additional tasks from starting and attempt to cancel in-progress API calls.Addresses #16