org.klomp.snark.dht

## Class Torrents

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - java.util.concurrent.ConcurrentHashMap<InfoHash,Peers>
    - - org.klomp.snark.dht.Torrents

- All Implemented Interfaces:
    Serializable, ConcurrentMap<InfoHash,Peers>, Map<InfoHash,Peers>

      class Torrents
      extends ConcurrentHashMap<InfoHash,Peers>

  Thread-safe collection of all torrents tracked by the DHT.

  This class extends ConcurrentHashMap to provide a thread-safe mapping from torrent info hash to the collection of peers participating in each torrent. It represents the complete set of torrents that the DHT tracker is currently tracking, along with all known peers for each torrent.

  This is the top-level data structure for the DHT tracker functionality. When peers announce themselves for torrents, they are added to the appropriate Peers collection within this structure. When get_peer requests are received, this structure is queried to find the relevant torrent and return its peers.

  The concurrent implementation ensures thread safety when multiple DHT operations are accessing or modifying torrent and peer data simultaneously, which is essential for a high-performance DHT tracker.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap

      `ConcurrentHashMap.KeySetView<K,V>`

    - ### Nested classes/interfaces inherited from class java.util.AbstractMap

      `AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Torrents()` Creates a new torrent collection with default initial capacity.

  - ### Method Summary

    - ### Methods inherited from class java.util.concurrent.ConcurrentHashMap

      `clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values`

    - ### Methods inherited from class java.util.AbstractMap

      `clone`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Torrents

          public Torrents()

      Creates a new torrent collection with default initial capacity.

      Uses the default ConcurrentHashMap constructor which provides good performance characteristics for most DHT tracking scenarios. The map will automatically resize as needed to accommodate the number of tracked torrents.