class StreamPool extends Object
Modifier and Type | Field and Description |
---|---|
private LinkedList |
freeList
Holds stream references in least recently used (released) order.
|
private int |
maxPoolSize
Maximum limit for the number of concurrent LogStreams
in the stream pool.
|
private static Logger |
persistenceLogger
Logger for lease related messages
|
private HashMap |
pool
Holds stream references by associated key
|
Constructor and Description |
---|
StreamPool(int size)
Simple constructor that creates a pool of given
size . |
Modifier and Type | Method and Description |
---|---|
(package private) void |
dump() |
private void |
ensurePoolSpace()
Ensures that room is available in the pool.
|
(package private) ControlLog |
getControlLog(File file)
Returns a ControlLog object for the specified file
from the pool if it already exists.
|
(package private) int |
getFreeSize() |
(package private) LogInputStream |
getLogInputStream(File file,
long offset)
Returns a LogInputStream object from the pool if it
already exists.
|
(package private) LogOutputStream |
getLogOutputStream(File file,
long offset)
Returns a LogOutputStream object for the specified file
from the pool if it already exists.
|
(package private) int |
getPoolSize() |
(package private) void |
releaseLogStream(LogStream stream)
Marks a stream as available for closing.
|
(package private) void |
removeLogStream(LogStream stream)
Removes the given LogStream from the pool and closes it,
if possible.
|
private static final Logger persistenceLogger
private final int maxPoolSize
private final HashMap pool
private final LinkedList freeList
StreamPool(int size)
size
.IllegalArgumentException
- Thrown if the value of
maxPoolSize is less than 1.ControlLog getControlLog(File file) throws IOException
IOException
- if an I/O error occursLogInputStream getLogInputStream(File file, long offset) throws IOException
IOException
- if an I/O error occursLogOutputStream getLogOutputStream(File file, long offset) throws IOException
IOException
- if an I/O error occursprivate void ensurePoolSpace() throws IOException
IOException
- if an I/O error occursvoid releaseLogStream(LogStream stream)
void removeLogStream(LogStream stream)
int getPoolSize()
int getFreeSize()
void dump()
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.