Skip to content

Commit 61ec688

Browse files
committed
Merging fix for creating ranged gets from network retries into 3_5_1
1 parent b8357f5 commit 61ec688

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/strategy/transferstrategy/GetJobNetworkFailureRetryDecorator.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.spectralogic.ds3client.helpers.strategy.transferstrategy;
1717

1818
import com.google.common.collect.ImmutableCollection;
19+
import com.google.common.collect.ImmutableList;
1920
import com.google.common.collect.ImmutableMap;
2021
import com.google.common.collect.ImmutableMultimap;
2122
import com.spectralogic.ds3client.exceptions.ContentLengthNotMatchException;
@@ -25,6 +26,7 @@
2526
import com.spectralogic.ds3client.helpers.strategy.channelstrategy.ChannelStrategy;
2627
import com.spectralogic.ds3client.models.BulkObject;
2728
import com.spectralogic.ds3client.models.common.Range;
29+
import com.spectralogic.ds3client.utils.Guard;
2830

2931
import java.io.IOException;
3032
import java.util.HashMap;
@@ -125,12 +127,24 @@ private ImmutableCollection<Range> initializeRanges(final BulkObject blob, final
125127

126128
if (ranges == null) {
127129
final long numBytesTransferred = 0;
128-
ranges = updateRanges(ranges, numBytesTransferred, blob.getLength());
130+
ranges = adjustRangesForBlobOffset(updateRanges(ranges, numBytesTransferred, blob.getLength()), blob);
129131
}
130132

131133
return ranges;
132134
}
133135

136+
private ImmutableCollection<Range> adjustRangesForBlobOffset(final ImmutableCollection<Range> ranges, final BulkObject blob) {
137+
if (Guard.isNullOrEmpty(ranges) || ranges.size() > 1) {
138+
return ranges;
139+
}
140+
141+
final Range firstRange = ranges.iterator().next();
142+
143+
final long blobOffset = blob.getOffset();
144+
145+
return ImmutableList.of(new Range(firstRange.getStart() + blobOffset, firstRange.getEnd() + blobOffset));
146+
}
147+
134148
private ImmutableCollection<Range> updateRanges(final ImmutableCollection<Range> ranges,
135149
final long numBytesTransferred,
136150
final Long numBytesToTransfer)

0 commit comments

Comments
 (0)