Class ShortCircuitReplica

java.lang.Object
org.apache.hadoop.hdfs.shortcircuit.ShortCircuitReplica

@Private public class ShortCircuitReplica extends Object
A ShortCircuitReplica object contains file descriptors for a block that we are reading via short-circuit local reads. The file descriptors can be shared between multiple threads because all the operations we perform are stateless-- i.e., we use pread instead of read, to avoid using the shared position state.
  • Field Details

    • LOG

      public static final org.slf4j.Logger LOG
  • Constructor Details

  • Method Details

    • unref

      public void unref()
      Decrement the reference count.
    • addNoChecksumAnchor

      public boolean addNoChecksumAnchor()
      Try to add a no-checksum anchor to our shared memory slot. It is only possible to add this anchor when the block is mlocked on the Datanode. The DataNode will not munlock the block until the number of no-checksum anchors for the block reaches zero. This method does not require any synchronization.
      Returns:
      True if we successfully added a no-checksum anchor.
    • removeNoChecksumAnchor

      public void removeNoChecksumAnchor()
      Remove a no-checksum anchor for our shared memory slot. This method does not require any synchronization.
    • hasMmap

      @VisibleForTesting public boolean hasMmap()
      Check if the replica has an associated mmap that has been fully loaded. Must be called with the cache lock held.
    • getDataStream

      public FileInputStream getDataStream()
    • getMetaStream

      public FileInputStream getMetaStream()
    • getMetaHeader

      public BlockMetadataHeader getMetaHeader()
    • getKey

      public ExtendedBlockId getKey()
    • getOrCreateClientMmap

      public ClientMmap getOrCreateClientMmap(boolean anchor)
    • getEvictableTimeNs

      public Long getEvictableTimeNs()
      Get the evictable time in nanoseconds. Note: you must hold the cache lock to call this function.
      Returns:
      the evictable time in nanoseconds.
    • getSlot

      @VisibleForTesting public ShortCircuitShm.Slot getSlot()
    • toString

      public String toString()
      Convert the replica to a string for debugging purposes. Note that we can't take the lock here.
      Overrides:
      toString in class Object