Class ShortCircuitShm
java.lang.Object
org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm
- Direct Known Subclasses:
DfsClientShm
A shared memory segment used to implement short-circuit reads.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIdentifies a DfsClientShm.classA slot containing information about a replica.static classUniquely identifies a slot.class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionShortCircuitShm(ShortCircuitShm.ShmId shmId, FileInputStream stream) Create the ShortCircuitShm. -
Method Summary
Modifier and TypeMethodDescriptionfinal ShortCircuitShm.SlotallocAndRegisterSlot(ExtendedBlockId blockId) Allocate a new slot and register it.voidfree()final ShortCircuitShm.ShmIdgetShmId()final ShortCircuitShm.SlotgetSlot(int slotIdx) final booleanisEmpty()Determine if this shared memory object is empty.final booleanisFull()Determine if this shared memory object is full.final ShortCircuitShm.SlotregisterSlot(int slotIdx, ExtendedBlockId blockId) Register a slot.Iterate over all allocated slots.toString()final voidunregisterSlot(int slotIdx) Unregisters a slot.
-
Field Details
-
BYTES_PER_SLOT
protected static final int BYTES_PER_SLOT- See Also:
-
-
Constructor Details
-
ShortCircuitShm
Create the ShortCircuitShm.- Parameters:
shmId- The ID to use.stream- The stream that we're going to use to create this shared memory segment. Although this is a FileInputStream, we are going to assume that the underlying file descriptor is writable as well as readable. It would be more appropriate to use a RandomAccessFile here, but that class does not have any public accessor which returns a FileDescriptor, unlike FileInputStream.- Throws:
IOException
-
-
Method Details
-
getShmId
-
isEmpty
public final boolean isEmpty()Determine if this shared memory object is empty.- Returns:
- True if the shared memory object is empty.
-
isFull
public final boolean isFull()Determine if this shared memory object is full.- Returns:
- True if the shared memory object is full.
-
allocAndRegisterSlot
Allocate a new slot and register it. This function chooses an empty slot, initializes it, and then returns the relevant Slot object.- Returns:
- The new slot.
-
getSlot
public final ShortCircuitShm.Slot getSlot(int slotIdx) throws org.apache.hadoop.fs.InvalidRequestException - Throws:
org.apache.hadoop.fs.InvalidRequestException
-
registerSlot
public final ShortCircuitShm.Slot registerSlot(int slotIdx, ExtendedBlockId blockId) throws org.apache.hadoop.fs.InvalidRequestException Register a slot. This function looks at a slot which has already been initialized (by another process), and registers it with us. Then, it returns the relevant Slot object.- Returns:
- The slot.
- Throws:
org.apache.hadoop.fs.InvalidRequestException- If the slot index we're trying to allocate has not been initialized, or is already in use.
-
unregisterSlot
public final void unregisterSlot(int slotIdx) Unregisters a slot. This doesn't alter the contents of the slot. It just means- Parameters:
slotIdx- Index of the slot to unregister.
-
slotIterator
Iterate over all allocated slots. Note that this method isn't safe if- Returns:
- The slot iterator.
-
free
public void free() -
toString
-