|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jini.mercury.StreamPool
class StreamPool
This class provides a pool of LogStream objects. Each LogStream has an associated FileDescriptor, which is the system resource we are trying to manage. This pool limits the (user configurable) number of concurrent, open FileDescriptors.
Field Summary | |
---|---|
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 Summary | |
---|---|
StreamPool(int size)
Simple constructor that creates a pool of given size . |
Method Summary | |
---|---|
(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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger persistenceLogger
private final int maxPoolSize
private final HashMap pool
private final LinkedList freeList
Constructor Detail |
---|
StreamPool(int size)
size
.
IllegalArgumentException
- Thrown if the value of
maxPoolSize is less than 1.Method Detail |
---|
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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |