Package alluxio
Class StreamCache
- java.lang.Object
-
- alluxio.StreamCache
-
@ThreadSafe public final class StreamCache extends java.lang.ObjectCache for storing file input and output streams. When a stream is added to the cache, the cache returns a unique ID that can be used for future lookups of the stream. The streams are automatically closed when their cache entry is invalidated or after being inactive for an extended period of time.
-
-
Constructor Summary
Constructors Constructor Description StreamCache(long timeoutMs)Creates a new instance ofStreamCache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description alluxio.client.file.FileInStreamgetInStream(java.lang.Integer key)alluxio.client.file.FileOutStreamgetOutStream(java.lang.Integer key)java.io.Closeableinvalidate(java.lang.Integer key)java.lang.Integerput(alluxio.client.file.FileInStream is)java.lang.Integerput(alluxio.client.file.FileOutStream os)longsize()
-
-
-
Constructor Detail
-
StreamCache
public StreamCache(long timeoutMs)
Creates a new instance ofStreamCache.- Parameters:
timeoutMs- the timeout (in milliseconds) for the stream cache eviction
-
-
Method Detail
-
getInStream
public alluxio.client.file.FileInStream getInStream(java.lang.Integer key)
- Parameters:
key- the key to get the stream for- Returns:
- the stream or null if the cache contains no stream for the given key
-
getOutStream
public alluxio.client.file.FileOutStream getOutStream(java.lang.Integer key)
- Parameters:
key- the key to get the stream for- Returns:
- the stream or null if the cache contains no stream for the given key
-
put
public java.lang.Integer put(alluxio.client.file.FileInStream is)
- Parameters:
is- the stream to cache- Returns:
- the key for looking up the stream
-
put
public java.lang.Integer put(alluxio.client.file.FileOutStream os)
- Parameters:
os- the stream to cache- Returns:
- the key for looking up the stream
-
invalidate
@Nullable public java.io.Closeable invalidate(java.lang.Integer key)
- Parameters:
key- the key for the stream to invalidate- Returns:
- the invalidated stream or null if the cache contains no stream for the given key
-
size
public long size()
- Returns:
- total size of the cache for both input streams and output streams
-
-