org.lastbamboo.common.download
Interface RangeTracker

All Known Implementing Classes:
RangeTrackerAdapter, RangeTrackerImpl

public interface RangeTracker

Interface for tracking download ranges.


Method Summary
 long getBytesRead()
          Accessor for the number of bytes read.
 org.littleshoot.util.Optional<org.apache.commons.lang.math.LongRange> getNextRange()
          Gets the next range to download.
 int getNumChunks()
          Accessor for the number of chunks to download.
 boolean hasMoreRanges()
          Returns whether or not there are available ranges to download.
 void onRangeComplete(org.apache.commons.lang.math.LongRange range)
          Called when we've completed downloading the specified range.
 void onRangeFailed(org.apache.commons.lang.math.LongRange range)
          Called when the attempt to download the specified range has failed.
 

Method Detail

getNextRange

org.littleshoot.util.Optional<org.apache.commons.lang.math.LongRange> getNextRange()
Gets the next range to download. This will be the highest priorty range based on a range ranking that will typically preference the beginning of files for streaming but that will also add randomization to avoid many hosts missing the same pieces, particularly when sharing partial files.

Returns:
The next range to download.

hasMoreRanges

boolean hasMoreRanges()
Returns whether or not there are available ranges to download.

Returns:
true if there are more ranges to download, otherwise false.

onRangeComplete

void onRangeComplete(org.apache.commons.lang.math.LongRange range)
Called when we've completed downloading the specified range.

Parameters:
range - The completed range.

onRangeFailed

void onRangeFailed(org.apache.commons.lang.math.LongRange range)
Called when the attempt to download the specified range has failed. This indicates the range should be added again to the queue of ranges to assign.

Parameters:
range - The range that could not be downloaded.

getNumChunks

int getNumChunks()
Accessor for the number of chunks to download.

Returns:
The number of chunks to download.

getBytesRead

long getBytesRead()
Accessor for the number of bytes read.

Returns:
The number of bytes read.


Copyright © 2013 LittleShoot. All Rights Reserved.