-
Notifications
You must be signed in to change notification settings - Fork 13
Streaming Fix - JSDK-298 #579
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,10 @@ | |
| import com.google.common.collect.HashMultimap; | ||
| import com.google.common.collect.SetMultimap; | ||
| import com.spectralogic.ds3client.helpers.Ds3ClientHelpers; | ||
| import com.spectralogic.ds3client.helpers.channelbuilders.ReadOnlySeekableByteChannel; | ||
| import com.spectralogic.ds3client.models.BulkObject; | ||
| import com.spectralogic.ds3client.models.JobRequestType; | ||
| import com.spectralogic.ds3client.models.MasterObjectList; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.channels.SeekableByteChannel; | ||
|
|
@@ -40,6 +43,7 @@ public class SequentialChannelStrategy implements ChannelStrategy { | |
| private final ChannelStrategy channelStrategyDelegate; | ||
| private final Ds3ClientHelpers.ObjectChannelBuilder objectChannelBuilder; | ||
| private final ChannelPreparable channelPreparer; | ||
| private final MasterObjectList masterObjectList; | ||
|
|
||
| /** | ||
| * @param channelStrategy The instance of {@link ChannelStrategy} that holds the 1 channel reference a blob needs | ||
|
|
@@ -51,12 +55,14 @@ public class SequentialChannelStrategy implements ChannelStrategy { | |
| * either {@link TruncatingChannelPreparable} or {@link NullChannelPreparable}. | ||
| */ | ||
| public SequentialChannelStrategy(final ChannelStrategy channelStrategy, | ||
| final Ds3ClientHelpers.ObjectChannelBuilder objectChannelBuilder, | ||
| final ChannelPreparable channelPreparer) | ||
| final Ds3ClientHelpers.ObjectChannelBuilder objectChannelBuilder, | ||
| final ChannelPreparable channelPreparer, | ||
| final MasterObjectList masterObjectList) | ||
| { | ||
| channelStrategyDelegate = channelStrategy; | ||
| this.objectChannelBuilder = objectChannelBuilder; | ||
| this.channelPreparer = channelPreparer; | ||
| this.masterObjectList = masterObjectList; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -109,10 +115,19 @@ public void releaseChannelForBlob(final SeekableByteChannel seekableByteChannel, | |
|
|
||
| blobNameOffsetMap.remove(blobName, blob.getOffset()); | ||
|
|
||
| if (blobNameOffsetMap.get(blobName).size() == 0) { | ||
| final Long maximumOffset = masterObjectList.getObjects().stream() | ||
| .flatMap(objects -> objects.getObjects().stream()) | ||
| .filter(bulkObject -> bulkObject.getName().equals(blobName)) | ||
| .map(bulkObject -> bulkObject.getOffset()) | ||
| .max(Long::compareTo).orElseGet(() -> blob.getOffset()); | ||
|
|
||
| final boolean isReadOnly = ((SeekableByteChannelDecorator) seekableByteChannel).wrappedSeekableByteChannel() instanceof ReadOnlySeekableByteChannel; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the cast here needed in order to perform the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We know it is a SeekableByteChannelDecorator because we wrap it further up, but the wrappedSeekableByteChannel() is only on the Decorator |
||
|
|
||
| if (blobNameOffsetMap.get(blobName).size() == 0 && (blob.getOffset() == maximumOffset || !(isReadOnly))) { | ||
| blobNameChannelMap.remove(blobName); | ||
| channelStrategyDelegate.releaseChannelForBlob(((SeekableByteChannelDecorator)seekableByteChannel).wrappedSeekableByteChannel(), blob); | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -475,34 +475,21 @@ private TransferStrategy makeStreamingPutTransferStrategy() { | |
| getOrMakeTransferRetryDecorator(); | ||
|
|
||
| return makeTransferStrategy( | ||
| new BlobStrategyMaker() { | ||
| @Override | ||
| public BlobStrategy makeBlobStrategy(final Ds3Client client, | ||
| final MasterObjectList masterObjectList, | ||
| final EventDispatcher eventDispatcher) | ||
| { | ||
| return new PutSequentialBlobStrategy(ds3Client, | ||
| masterObjectList, | ||
| eventDispatcher, | ||
| getOrMakeChunkAttemptRetryBehavior(), | ||
| getOrMakeChunkAllocationRetryDelayBehavior() | ||
| ); | ||
| } | ||
| }, | ||
| new TransferMethodMaker() { | ||
| @Override | ||
| public TransferMethod makeTransferMethod() { | ||
| return makePutTransferMethod(); | ||
| } | ||
| }); | ||
| (client, masterObjectList, eventDispatcher) -> new PutSequentialBlobStrategy(ds3Client, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| masterObjectList, | ||
| eventDispatcher, | ||
| getOrMakeChunkAttemptRetryBehavior(), | ||
| getOrMakeChunkAllocationRetryDelayBehavior() | ||
| ), | ||
| this::makePutTransferMethod); | ||
| } | ||
|
|
||
| private void maybeMakeStreamedPutChannelStrategy() { | ||
| if (channelStrategy == null) { | ||
| Preconditions.checkNotNull(channelBuilder, "channelBuilder my not be null"); | ||
|
|
||
| channelStrategy = new SequentialChannelStrategy(new SequentialFileReaderChannelStrategy(channelBuilder), | ||
| channelBuilder, new NullChannelPreparable()); | ||
| channelBuilder, new NullChannelPreparable(), masterObjectList); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -823,30 +810,20 @@ private TransferStrategy makeStreamingGetTransferStrategy() { | |
| getOrMakeTransferRetryDecorator(); | ||
|
|
||
| return makeTransferStrategy( | ||
| new BlobStrategyMaker() { | ||
| @Override | ||
| public BlobStrategy makeBlobStrategy(final Ds3Client client, final MasterObjectList masterObjectList, final EventDispatcher eventDispatcher) { | ||
| return new GetSequentialBlobStrategy(ds3Client, | ||
| masterObjectList, | ||
| eventDispatcher, | ||
| getOrMakeChunkAttemptRetryBehavior(), | ||
| getOrMakeChunkAllocationRetryDelayBehavior()); | ||
| } | ||
| }, | ||
| new TransferMethodMaker() { | ||
| @Override | ||
| public TransferMethod makeTransferMethod() { | ||
| return makeGetTransferMethod(); | ||
| } | ||
| }); | ||
| (client, masterObjectList, eventDispatcher) -> new GetSequentialBlobStrategy(ds3Client, | ||
| masterObjectList, | ||
| eventDispatcher, | ||
| getOrMakeChunkAttemptRetryBehavior(), | ||
| getOrMakeChunkAllocationRetryDelayBehavior()), | ||
| this::makeGetTransferMethod); | ||
| } | ||
|
|
||
| private void maybeMakeSequentialGetChannelStrategy() { | ||
| if (channelStrategy == null) { | ||
| Preconditions.checkNotNull(channelBuilder, "channelBuilder my not be null"); | ||
|
|
||
| channelStrategy = new SequentialChannelStrategy(new SequentialFileWriterChannelStrategy(channelBuilder), | ||
| channelBuilder, new TruncatingChannelPreparable()); | ||
| channelBuilder, new TruncatingChannelPreparable(), masterObjectList); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.spectralogic.ds3client.utils | ||
|
|
||
| import com.spectralogic.ds3client.helpers.channelbuilders.ReadOnlySeekableByteChannel | ||
|
|
||
| class ReadOnlySeekableByteChannelInputStream( | ||
| readOnlySeekableByteChannel: ReadOnlySeekableByteChannel | ||
| ) : SeekableByteChannelInputStream(readOnlySeekableByteChannel) { | ||
| override fun reset(): Unit = Unit | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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.
Did the lack of this cause problems when a blob was over 4GB?
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.
This is one of the places it failed, I can't say if this is wholly the issue though.