org.lastbamboo.common.download
Class SourceRankerImpl

java.lang.Object
  extended by org.lastbamboo.common.download.SourceRankerImpl
All Implemented Interfaces:
SourceRanker

public class SourceRankerImpl
extends Object
implements SourceRanker

Class that ranks available download sources. This will provide callers with the best available source for downloading the next chunk.


Constructor Summary
SourceRankerImpl(Comparator<RangeDownloader> comparator)
          Creates a new ranker.
 
Method Summary
 RangeDownloader getBestSource()
          Gets the best available source to download from.
 boolean hasMoreSources()
          Returns whether or not this ranker has more sources to download from.
 void onAvailable(RangeDownloader downloader)
          Notifies the ranker that the given source is available for work.
 void onFailed()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SourceRankerImpl

public SourceRankerImpl(Comparator<RangeDownloader> comparator)
Creates a new ranker.

Parameters:
comparator - The comparator to use for judging sources.
Method Detail

hasMoreSources

public boolean hasMoreSources()
Description copied from interface: SourceRanker
Returns whether or not this ranker has more sources to download from.

Specified by:
hasMoreSources in interface SourceRanker
Returns:
true if this ranker has more sources, otherwise false.

getBestSource

public RangeDownloader getBestSource()
Description copied from interface: SourceRanker
Gets the best available source to download from. The best source will typically just be the fastest source.

Specified by:
getBestSource in interface SourceRanker
Returns:
The best source to download from.

onAvailable

public void onAvailable(RangeDownloader downloader)
Description copied from interface: SourceRanker
Notifies the ranker that the given source is available for work. This will typically be called after a download worker has completed downloading its assigned range, for example.

Specified by:
onAvailable in interface SourceRanker
Parameters:
downloader - The available downloader.

onFailed

public void onFailed()
Specified by:
onFailed in interface SourceRanker


Copyright © 2013 LittleShoot. All Rights Reserved.