|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.mdr.persistence.btreeimpl.btreestorage.FileCache
public class FileCache
FileCache provides transactional cached access to a set of files. Changes to these files are accumulated both in memory and on disk until a commit is requested, at which time they are flushed to disk. If the program exits for any reason without comitting, any changes which were written to disk are rolled back to the last commit point the next time the FileCache is opened.
Nested Class Summary | |
---|---|
static interface |
FileCache.NotifyOnCommit
An object which needs to be notified before the cache commits (for instance, to write any changes to the cache before the cache is flushed to disk) implements this interface, and calls addNotifier on the cache. |
Constructor Summary | |
---|---|
FileCache(int pgSize,
int numBufs,
java.lang.String[] names,
java.lang.String logName)
Create the cache and open the files. |
Method Summary | |
---|---|
void |
abort()
close all files without comitting |
void |
addNotifier(FileCache.NotifyOnCommit notified)
Add to the list of objects to be notified before commit |
void |
close()
commit all changes and close all cached files |
void |
commit()
commit all changes |
void |
dumpCache(java.io.PrintStream strm)
for debugging |
CachedPage |
getPage(int fileidx,
int pageNum)
Get the single page at the desired offset into the file This implicitly pins that pages. |
CachedPage[] |
getPages(int fileidx,
int first,
int size)
Get the pages which contain the desired bytes from the file This implicitly pins these pages. |
void |
setWritable(CachedPage page)
Make the specified page writable. |
void |
setWritable(CachedPage[] pages)
Make the specified pages writable. |
void |
showStats(java.io.PrintStream strm)
Show caching statistics |
void |
showStats(java.io.PrintWriter strm)
Show caching statistics |
void |
unpin(CachedPage page)
unpin a page. |
void |
unpin(CachedPage[] pages)
unpin a set of pages. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileCache(int pgSize, int numBufs, java.lang.String[] names, java.lang.String logName) throws StorageException
pgSize
- the cache's page sizenumBufs
- the number of page buffers to createnames
- the files to access via the cachelogName
- the name of the log file
StorageException
- I/O error opening or reading the files
BadParameterException
- if the file do not have identical file
headers, or the log file exists but is not consistent with the files
ConsistencyException
- if the log file exists and is corruptedMethod Detail |
---|
public void abort() throws StorageException
StorageException
- I/O error closing the filespublic void close() throws StorageException
StorageException
- I/O error closing the filespublic void commit() throws StorageException
StorageException
- I/O error writing the filespublic void unpin(CachedPage[] pages) throws StorageException
pages
- the pages to unpin
BadParameterException
- if the page is not pinned
StorageException
public void unpin(CachedPage page) throws StorageException
page
- the page to unpin
BadParameterException
- if any of the pages are not pinned
StorageException
public CachedPage[] getPages(int fileidx, int first, int size) throws StorageException
fileidx
- the index of the file containing the page.first
- the number of the first page to getlength
- the number of pages to get
StorageException
- I/O error reading the pagespublic CachedPage getPage(int fileidx, int pageNum) throws StorageException
fileidx
- the index of the file containing the page.pageNum
- the page number to get
StorageException
- I/O error reading the pagepublic void setWritable(CachedPage page) throws StorageException
page
- The page to be made writable.
StorageException
- I/O error logging the pagepublic void setWritable(CachedPage[] pages) throws StorageException
pages
- The pages to be made writable.
StorageException
- I/O error logging the pagespublic void dumpCache(java.io.PrintStream strm)
public void showStats(java.io.PrintStream strm)
public void showStats(java.io.PrintWriter strm)
public void addNotifier(FileCache.NotifyOnCommit notified)
notified
- the obect to add to the list
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |