@NotThreadSafe public class BlockInStream extends InputStream implements BoundedStream, alluxio.Seekable, PositionedReadable
InputStream implementation that is based on DataReaders to
stream data chunk by chunk.| Modifier and Type | Class and Description |
|---|---|
static class |
BlockInStream.BlockInStreamSource
the source tracking where the block is from.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BlockInStream(DataReader.Factory dataReaderFactory,
alluxio.wire.WorkerNetAddress address,
BlockInStream.BlockInStreamSource blockSource,
long id,
long length)
Creates an instance of
BlockInStream. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static BlockInStream |
create(FileSystemContext context,
alluxio.wire.BlockInfo info,
alluxio.wire.WorkerNetAddress dataSource,
BlockInStream.BlockInStreamSource dataSourceType,
InStreamOptions options)
Creates a
BlockInStream. |
static BlockInStream |
createRemoteBlockInStream(FileSystemContext context,
long blockId,
alluxio.wire.WorkerNetAddress address,
BlockInStream.BlockInStreamSource blockSource,
long blockSize,
alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions ufsOptions)
Creates a
BlockInStream to read from a specific remote server. |
alluxio.wire.WorkerNetAddress |
getAddress() |
long |
getId() |
long |
getPos() |
BlockInStream.BlockInStreamSource |
getSource() |
boolean |
isShortCircuit() |
int |
positionedRead(long pos,
byte[] b,
int off,
int len)
Reads up to the specified number of bytes, from a given position within a file, and return the
number of bytes read.
|
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
long |
remaining() |
void |
seek(long pos) |
long |
skip(long n) |
available, mark, markSupported, resetprotected BlockInStream(DataReader.Factory dataReaderFactory, alluxio.wire.WorkerNetAddress address, BlockInStream.BlockInStreamSource blockSource, long id, long length)
BlockInStream.dataReaderFactory - the data reader factoryaddress - the address of the gRPC data serverblockSource - the source location of the blockid - the ID (either block ID or UFS file ID)length - the lengthpublic static BlockInStream create(FileSystemContext context, alluxio.wire.BlockInfo info, alluxio.wire.WorkerNetAddress dataSource, BlockInStream.BlockInStreamSource dataSourceType, InStreamOptions options) throws IOException
BlockInStream.
One of several read behaviors:
1. Domain socket - if the data source is the local worker and the local worker has a domain
socket server
2. Short-Circuit - if the data source is the local worker
3. Local Loopback Read - if the data source is the local worker and short circuit is disabled
4. Read from remote worker - if the data source is a remote worker
5. UFS Read from worker - if the data source is UFS, read from the UFS policy's designated
worker (ufs -> local or remote worker -> client)context - the file system contextinfo - the block infodataSource - the Alluxio worker which should read the datadataSourceType - the source location of the blockoptions - the instream optionsBlockInStream objectIOExceptionpublic static BlockInStream createRemoteBlockInStream(FileSystemContext context, long blockId, alluxio.wire.WorkerNetAddress address, BlockInStream.BlockInStreamSource blockSource, long blockSize, alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions ufsOptions)
BlockInStream to read from a specific remote server. Should only be used
in cases where the data source and method of reading is known, ie. worker - worker
communication.context - the file system contextblockId - the block idaddress - the address of the gRPC data serverblockSource - the source location of the blockblockSize - the size of the blockufsOptions - the ufs read optionsBlockInStream createdpublic long getPos()
getPos in interface alluxio.Positionedpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic int positionedRead(long pos,
byte[] b,
int off,
int len)
throws IOException
PositionedReadablepositionedRead in interface PositionedReadablepos - position within fileb - destination bufferoff - offset in the bufferlen - number of bytes to readIOExceptionpublic long remaining()
remaining in interface BoundedStreampublic void seek(long pos)
throws IOException
seek in interface alluxio.SeekableIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic boolean isShortCircuit()
public alluxio.wire.WorkerNetAddress getAddress()
public BlockInStream.BlockInStreamSource getSource()
public long getId()
Copyright © 2024. All Rights Reserved.