Class ShortCircuitReplica
java.lang.Object
org.apache.hadoop.hdfs.shortcircuit.ShortCircuitReplica
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionShortCircuitReplica(ExtendedBlockId key, FileInputStream dataStream, FileInputStream metaStream, ShortCircuitCache cache, long creationTimeMs, ShortCircuitShm.Slot slot) -
Method Summary
Modifier and TypeMethodDescriptionbooleanTry to add a no-checksum anchor to our shared memory slot.Get the evictable time in nanoseconds.getKey()getOrCreateClientMmap(boolean anchor) getSlot()booleanhasMmap()Check if the replica has an associated mmap that has been fully loaded.voidRemove a no-checksum anchor for our shared memory slot.toString()Convert the replica to a string for debugging purposes.voidunref()Decrement the reference count.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
ShortCircuitReplica
public ShortCircuitReplica(ExtendedBlockId key, FileInputStream dataStream, FileInputStream metaStream, ShortCircuitCache cache, long creationTimeMs, ShortCircuitShm.Slot slot) throws IOException - Throws:
IOException
-
-
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
-
getMetaStream
-
getMetaHeader
-
getKey
-
getOrCreateClientMmap
-
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
-
toString
Convert the replica to a string for debugging purposes. Note that we can't take the lock here.
-