public class FileCache
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
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 and Description |
|---|
FileCache(int pgSize,
int numBufs,
java.lang.String[] names,
java.lang.String logName)
Create the cache and open the files.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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 fileStorageException - I/O error opening or reading the filesBadParameterException - if the file do not have identical file
headers, or the log file exists but is not consistent with the filesConsistencyException - if the log file exists and is corruptedpublic 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 unpinBadParameterException - if the page is not pinnedStorageExceptionpublic void unpin(CachedPage page) throws StorageException
page - the page to unpinBadParameterException - if any of the pages are not pinnedStorageExceptionpublic 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 getStorageException - 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 getStorageException - 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 listCopyright © 2005-2012 Apache Software Foundation. All Rights Reserved.