PeerCache (Apache Hadoop HDFS Client 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs, class: PeerCache

Package org.apache.hadoop.hdfs

# Class PeerCache

java.lang.Object
org.apache.hadoop.hdfs.PeerCache

@Unstable @Private @VisibleForTesting public class PeerCache extends Object
A cache of input stream sockets to Data Node.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PeerCache(int c, long e)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Peer`
  `get(DatanodeID dnId, boolean isDomain)`
  Get a cached peer connected to the given DataNode.
  `void`
  `put(DatanodeID dnId, Peer peer)`
  Give an unused socket to the cache.
  `int`
  `size()`

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PeerCache

    public PeerCache(int c, long e)

- ## Method Details

  - ### get

    public Peer get(DatanodeID dnId, boolean isDomain)
    Get a cached peer connected to the given DataNode.
    Parameters:
      `dnId` - The DataNode to get a Peer for.
      `isDomain` - Whether to retrieve a DomainPeer or not.
    Returns:
      An open Peer connected to the DN, or null if none was found.

  - ### put

    public void put(DatanodeID dnId, Peer peer)
    Give an unused socket to the cache.

  - ### size

    public int size()