@ThreadSafe public class UfsInputStreamManager extends Object
PropertyKey.WORKER_UFS_INSTREAM_CACHE_EXPIRE_MS
.
An under storage file maybe opened with multiple input streams at the same time. The manager uses
UfsInputStreamIdSet
to track the in-use input stream and the available ones. The manager
closes the input streams after they are expired and not in-use anymore. Lock
UfsInputStreamIdSet
before access, and in addition to that, lock
mFileIdToInputStreamIds
before the resource retrieval.Constructor and Description |
---|
UfsInputStreamManager()
Creates a new
UfsInputStreamManager . |
Modifier and Type | Method and Description |
---|---|
InputStream |
acquire(UnderFileSystem ufs,
String path,
long fileId,
OpenOptions openOptions)
Acquires an input stream.
|
InputStream |
acquire(UnderFileSystem ufs,
String path,
long fileId,
OpenOptions openOptions,
boolean reuse)
Acquires an input stream.
|
void |
invalidate(alluxio.worker.block.CachedSeekableInputStream inputStream)
Invalidates an input stream from the cache.
|
void |
release(InputStream inputStream)
Releases an input stream.
|
public UfsInputStreamManager()
UfsInputStreamManager
.public void release(InputStream inputStream) throws IOException
inputStream
- the input stream to releaseIOException
- when input stream fails to closepublic void invalidate(alluxio.worker.block.CachedSeekableInputStream inputStream) throws IOException
inputStream
- the cached input streamIOException
- when the invalidated input stream fails to releasepublic InputStream acquire(UnderFileSystem ufs, String path, long fileId, OpenOptions openOptions) throws IOException
ufs
- the under file systempath
- the path to the under storage filefileId
- the file idopenOptions
- the open optionsIOException
- if the input stream fails to openpublic InputStream acquire(UnderFileSystem ufs, String path, long fileId, OpenOptions openOptions, boolean reuse) throws IOException
ufs
- the under file systempath
- the path to the under storage filefileId
- the file idopenOptions
- the open optionsreuse
- true to reuse existing input stream, otherwise acquire a new streamIOException
- if the input stream fails to openCopyright © 2023. All Rights Reserved.