Package org.apache.hadoop.hdfs
Class DFSStripedInputStream
java.lang.Object
java.io.InputStream
org.apache.hadoop.fs.FSInputStream
org.apache.hadoop.hdfs.DFSInputStream
org.apache.hadoop.hdfs.DFSStripedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.fs.ByteBufferPositionedReadable,org.apache.hadoop.fs.ByteBufferReadable,org.apache.hadoop.fs.CanSetDropBehind,org.apache.hadoop.fs.CanSetReadahead,org.apache.hadoop.fs.CanUnbuffer,org.apache.hadoop.fs.HasEnhancedByteBufferAccess,org.apache.hadoop.fs.PositionedReadable,org.apache.hadoop.fs.Seekable,org.apache.hadoop.fs.StreamCapabilities
DFSStripedInputStream reads from striped block groups.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.fs.StreamCapabilities
org.apache.hadoop.fs.StreamCapabilities.StreamCapability -
Field Summary
FieldsFields inherited from class org.apache.hadoop.hdfs.DFSInputStream
blockEnd, cachingStrategy, closed, currentLocatedBlock, dfsClient, failures, infoLock, locatedBlocks, pos, readStatistics, src, tcpReadsDisabledForTesting, verifyChecksumFields inherited from interface org.apache.hadoop.fs.StreamCapabilities
ABORTABLE_STREAM, DROPBEHIND, HFLUSH, HSYNC, IOSTATISTICS, IOSTATISTICS_CONTEXT, PREADBYTEBUFFER, READAHEAD, READBYTEBUFFER, UNBUFFER, VECTOREDIO, VECTOREDIO_BUFFERS_SLICED -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close it down!protected voidExtend the super method with the logic of switching between cells.protected voidcloseReader(org.apache.hadoop.hdfs.StripeReader.BlockReaderInfo readerInfo) protected voidfetchBlockByteRange(LocatedBlock block, long start, long end, ByteBuffer buf, DFSUtilClient.CorruptedBlocks corruptedBlocks, Map<InetSocketAddress, List<IOException>> exceptionMap) Real implementation of pread.protected org.apache.hadoop.io.ByteBufferPoolprotected ByteBufferprotected ByteBufferprotected ThreadPoolExecutorread(org.apache.hadoop.io.ByteBufferPool bufferPool, int maxLength, EnumSet<org.apache.hadoop.fs.ReadOption> opts) May need online read recovery, zero-copy read doesn't make sense, so don't support it.protected intreadWithStrategy(org.apache.hadoop.hdfs.ReaderStrategy strategy) protected LocatedBlockrefreshLocatedBlock(LocatedBlock block) The super methodDFSInputStream.refreshLocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock)refreshes cached LocatedBlock by executingDFSInputStream.getBlockAt(long)again.voidreleaseBuffer(ByteBuffer buffer) protected voidreportLostBlock(LocatedBlock lostBlock, Collection<DatanodeInfo> ignoredNodes) Warn the user of a lost blockvoidseek(long targetPos) Seek to a new arbitrary location.booleanseekToNewSource(long targetPos) Seek to given position on a node other than the current node.voidunbuffer()Methods inherited from class org.apache.hadoop.hdfs.DFSInputStream
addToLocalDeadNodes, available, clearReadStatistics, fetchBlockAt, getAllBlocks, getBestNodeDNAddrPair, getBlockAt, getBlockReader, getCurrentBlock, getCurrentBlockLocationsLength, getCurrentDatanode, getDFSClient, getFileEncryptionInfo, getFileLength, getHedgedReadOpsLoopNumForTesting, getLocalDeadNodes, getLocatedBlocks, getPos, getReadStatistics, getSrc, hasCapability, mark, markSupported, maybeRegisterBlockRefresh, read, read, read, read, read, readFully, removeFromLocalDeadNodes, reportCheckSumFailure, reset, setDropBehind, setReadahead, skip, tokenRefetchNeededMethods inherited from class org.apache.hadoop.fs.FSInputStream
readFully, readFully, toString, validatePositionedReadArgsMethods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.fs.PositionedReadable
maxReadSizeForVectorReads, minSeekForVectorReads, readVectored, readVectored
-
Field Details
-
parityBuf
-
-
Method Details
-
getParityBuffer
-
getCurStripeBuf
-
getBufferPool
protected org.apache.hadoop.io.ByteBufferPool getBufferPool() -
getStripedReadsThreadPool
-
close
Description copied from class:DFSInputStreamClose it down!- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classDFSInputStream- Throws:
IOException
-
closeCurrentBlockReaders
protected void closeCurrentBlockReaders()Extend the super method with the logic of switching between cells. When reaching the end of a cell, proceed to the next cell and read it with the next blockReader.- Overrides:
closeCurrentBlockReadersin classDFSInputStream
-
closeReader
protected void closeReader(org.apache.hadoop.hdfs.StripeReader.BlockReaderInfo readerInfo) -
seek
Seek to a new arbitrary location.- Specified by:
seekin interfaceorg.apache.hadoop.fs.Seekable- Overrides:
seekin classDFSInputStream- Throws:
IOException
-
seekToNewSource
Description copied from class:DFSInputStreamSeek to given position on a node other than the current node. If a node other than the current node is found, then returns true. If another node could not be found, then returns false.- Specified by:
seekToNewSourcein interfaceorg.apache.hadoop.fs.Seekable- Overrides:
seekToNewSourcein classDFSInputStream- Throws:
IOException
-
readWithStrategy
- Overrides:
readWithStrategyin classDFSInputStream- Throws:
IOException
-
refreshLocatedBlock
The super methodDFSInputStream.refreshLocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock)refreshes cached LocatedBlock by executingDFSInputStream.getBlockAt(long)again. This method extends the logic by first remembering the index of the internal block, and re-parsing the refreshed block group with the same index.- Overrides:
refreshLocatedBlockin classDFSInputStream- Parameters:
block- The currently cached block locations- Returns:
- Refreshed block locations
- Throws:
IOException
-
fetchBlockByteRange
protected void fetchBlockByteRange(LocatedBlock block, long start, long end, ByteBuffer buf, DFSUtilClient.CorruptedBlocks corruptedBlocks, Map<InetSocketAddress, List<IOException>> exceptionMap) throws IOExceptionReal implementation of pread.Note: exceptionMap is not populated with ioExceptions as what we added for DFSInputStream. If you need this function, please implement it.
- Overrides:
fetchBlockByteRangein classDFSInputStream- Throws:
IOException
-
reportLostBlock
Description copied from class:DFSInputStreamWarn the user of a lost block- Overrides:
reportLostBlockin classDFSInputStream
-
read
public ByteBuffer read(org.apache.hadoop.io.ByteBufferPool bufferPool, int maxLength, EnumSet<org.apache.hadoop.fs.ReadOption> opts) throws IOException, UnsupportedOperationException May need online read recovery, zero-copy read doesn't make sense, so don't support it.- Specified by:
readin interfaceorg.apache.hadoop.fs.HasEnhancedByteBufferAccess- Overrides:
readin classDFSInputStream- Throws:
IOExceptionUnsupportedOperationException
-
releaseBuffer
- Specified by:
releaseBufferin interfaceorg.apache.hadoop.fs.HasEnhancedByteBufferAccess- Overrides:
releaseBufferin classDFSInputStream
-
unbuffer
public void unbuffer()- Specified by:
unbufferin interfaceorg.apache.hadoop.fs.CanUnbuffer- Overrides:
unbufferin classDFSInputStream
-