java.io.Closeable, java.lang.AutoCloseable@Private
public class ShortCircuitCache
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
ShortCircuitCache.CacheVisitor |
|
static interface |
ShortCircuitCache.ShortCircuitReplicaCreator |
| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
LOG |
| Constructor | Description |
|---|---|
ShortCircuitCache(int maxTotalSize,
long maxNonMmappedEvictableLifespanMs,
int maxEvictableMmapedSize,
long maxEvictableMmapedLifespanMs,
long mmapRetryTimeoutMs,
long staleThresholdMs,
int shmInterruptCheckMs) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
accept(ShortCircuitCache.CacheVisitor visitor) |
|
ShortCircuitShm.Slot |
allocShmSlot(DatanodeInfo datanode,
DomainPeer peer,
org.apache.commons.lang3.mutable.MutableBoolean usedPeer,
ExtendedBlockId blockId,
java.lang.String clientName) |
Allocate a new shared memory slot.
|
void |
close() |
Close the cache and free all associated resources.
|
protected ShortCircuitReplicaInfo |
fetch(ExtendedBlockId key,
org.apache.hadoop.util.Waitable<ShortCircuitReplicaInfo> waitable) |
Fetch an existing ReplicaInfo object.
|
ShortCircuitReplicaInfo |
fetchOrCreate(ExtendedBlockId key,
ShortCircuitCache.ShortCircuitReplicaCreator creator) |
Fetch or create a replica.
|
void |
freeSlot(ShortCircuitShm.Slot slot) |
Free a slot immediately.
|
static ShortCircuitCache |
fromConf(DfsClientConf.ShortCircuitConf conf) |
|
DfsClientShmManager |
getDfsClientShmManager() |
|
int |
getReplicaInfoMapSize() |
Can be used in testing to verify whether a read went through SCR, after
the read is done and before the stream is closed.
|
long |
getStaleThresholdMs() |
|
void |
scheduleSlotReleaser(ShortCircuitShm.Slot slot) |
Schedule a shared memory slot to be released.
|
void |
setMaxTotalSize(int maxTotalSize) |
|
java.lang.String |
toString() |
public ShortCircuitCache(int maxTotalSize,
long maxNonMmappedEvictableLifespanMs,
int maxEvictableMmapedSize,
long maxEvictableMmapedLifespanMs,
long mmapRetryTimeoutMs,
long staleThresholdMs,
int shmInterruptCheckMs)
public static ShortCircuitCache fromConf(DfsClientConf.ShortCircuitConf conf)
public long getStaleThresholdMs()
@VisibleForTesting public void setMaxTotalSize(int maxTotalSize)
public ShortCircuitReplicaInfo fetchOrCreate(ExtendedBlockId key, ShortCircuitCache.ShortCircuitReplicaCreator creator)
key - Key to use for lookup.creator - Replica creator callback. Will be called without
the cache lock being held.@VisibleForTesting protected ShortCircuitReplicaInfo fetch(ExtendedBlockId key, org.apache.hadoop.util.Waitable<ShortCircuitReplicaInfo> waitable) throws org.apache.hadoop.ipc.RetriableException
key - The key that we're using.waitable - The waitable object to wait on.org.apache.hadoop.ipc.RetriableException - If the caller needs to retry.public void close()
close in interface java.lang.AutoCloseableclose in interface java.io.Closeable@VisibleForTesting public void accept(ShortCircuitCache.CacheVisitor visitor)
public java.lang.String toString()
toString in class java.lang.Objectpublic ShortCircuitShm.Slot allocShmSlot(DatanodeInfo datanode, DomainPeer peer, org.apache.commons.lang3.mutable.MutableBoolean usedPeer, ExtendedBlockId blockId, java.lang.String clientName) throws java.io.IOException
datanode - The datanode to allocate a shm slot with.peer - A peer connected to the datanode.usedPeer - Will be set to true if we use up the provided peer.blockId - The block id and block pool id of the block we're
allocating this slot for.clientName - The name of the DFSClient allocating the shared
memory.java.io.IOException - An exception if there was an error talking to
the datanode.public void freeSlot(ShortCircuitShm.Slot slot)
slot - The slot to free.public void scheduleSlotReleaser(ShortCircuitShm.Slot slot)
slot - The slot to release.@VisibleForTesting public DfsClientShmManager getDfsClientShmManager()
@VisibleForTesting public int getReplicaInfoMapSize()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.