Class EqualDistributor

  • All Implemented Interfaces:
    IPeerDistributor

    public class EqualDistributor
    extends Object
    implements IPeerDistributor
    An implementation of IPeerDistributor which attempts to equally distribute the peers. Note that this implementation does not considered the given limit to be hard limit. If the limit was reached and another torrent would get added this implementation will allow more peers to connect. Also when the calculated limit is smaller than 1, the limit will be increased to 1.
    • Constructor Detail

      • EqualDistributor

        public EqualDistributor​(TorrentClient torrentClient,
                                int globalLimit)
        Creates a distributor which attempts to equally distribute the peers over the torrents.
        Parameters:
        torrentClient - The torrent client for which this distributor is working.
        globalLimit - The soft limit on the amount of connections.
    • Method Detail

      • hasReachedPeerLimit

        public boolean hasReachedPeerLimit​(Torrent torrent)
        Specified by:
        hasReachedPeerLimit in interface IPeerDistributor
        Parameters:
        torrent - The torrent to calculate the limit for.
        Returns:
        true when the torrent has reached the calculated peer count limit.