org.lastbamboo.common.download
Class RangeTrackerAdapter

java.lang.Object
  extended by org.lastbamboo.common.download.RangeTrackerAdapter
All Implemented Interfaces:
RangeTracker

public class RangeTrackerAdapter
extends Object
implements RangeTracker

Adapter for a range tracker.


Constructor Summary
RangeTrackerAdapter()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RangeTrackerAdapter

public RangeTrackerAdapter()
Method Detail

getBytesRead

public long getBytesRead()
Description copied from interface: RangeTracker
Accessor for the number of bytes read.

Specified by:
getBytesRead in interface RangeTracker
Returns:
The number of bytes read.

getNextRange

public org.littleshoot.util.Optional<org.apache.commons.lang.math.LongRange> getNextRange()
Description copied from interface: RangeTracker
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.

Specified by:
getNextRange in interface RangeTracker
Returns:
The next range to download.

getNumChunks

public int getNumChunks()
Description copied from interface: RangeTracker
Accessor for the number of chunks to download.

Specified by:
getNumChunks in interface RangeTracker
Returns:
The number of chunks to download.

hasMoreRanges

public boolean hasMoreRanges()
Description copied from interface: RangeTracker
Returns whether or not there are available ranges to download.

Specified by:
hasMoreRanges in interface RangeTracker
Returns:
true if there are more ranges to download, otherwise false.

onRangeComplete

public void onRangeComplete(org.apache.commons.lang.math.LongRange range)
Description copied from interface: RangeTracker
Called when we've completed downloading the specified range.

Specified by:
onRangeComplete in interface RangeTracker
Parameters:
range - The completed range.

onRangeFailed

public void onRangeFailed(org.apache.commons.lang.math.LongRange range)
Description copied from interface: RangeTracker
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.

Specified by:
onRangeFailed in interface RangeTracker
Parameters:
range - The range that could not be downloaded.


Copyright © 2013 LittleShoot. All Rights Reserved.