org.lastbamboo.common.download
Class DefaultRangeSizeSelector

java.lang.Object
  extended by org.lastbamboo.common.download.DefaultRangeSizeSelector
All Implemented Interfaces:
RangeSizeSelector

public class DefaultRangeSizeSelector
extends Object
implements RangeSizeSelector

Class for selecting the size of download ranges based on the size of a file and the number of available sources.


Field Summary
static long DIFFERENTIAL_SPEED_FACTOR
          This is the factor that takes into account that different sources provide different download speeds.
static long MAX_CHUNK_SIZE
          The maximum size for chunks.
static long MIN_CHUNK_SIZE
          The minimum size for chunks.
 
Constructor Summary
DefaultRangeSizeSelector()
           
 
Method Summary
 long selectSize(long fileSize, int numSources)
          Selects the size of ranges based on the file size and the number of sources for the download.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_CHUNK_SIZE

public static final long MAX_CHUNK_SIZE
The maximum size for chunks.

See Also:
Constant Field Values

MIN_CHUNK_SIZE

public static final long MIN_CHUNK_SIZE
The minimum size for chunks.

See Also:
Constant Field Values

DIFFERENTIAL_SPEED_FACTOR

public static final long DIFFERENTIAL_SPEED_FACTOR
This is the factor that takes into account that different sources provide different download speeds. The extreme of this is a centralized CDN source versus a peer on a modem link, for example. We need to choose small enough chunks so that slower downloaders don't screw things up for the download as a whole.

See Also:
Constant Field Values
Constructor Detail

DefaultRangeSizeSelector

public DefaultRangeSizeSelector()
Method Detail

selectSize

public long selectSize(long fileSize,
                       int numSources)
Description copied from interface: RangeSizeSelector
Selects the size of ranges based on the file size and the number of sources for the download.

Specified by:
selectSize in interface RangeSizeSelector
Parameters:
fileSize - The size of the file.
numSources - The number of sources for the download.
Returns:
The size to use for each chunk.


Copyright © 2013 LittleShoot. All Rights Reserved.