public class MappedPageFactoryImpl extends Object implements IMappedPageFactory
| Modifier and Type | Field and Description |
|---|---|
static String |
PAGE_FILE_NAME |
static String |
PAGE_FILE_SUFFIX |
| Constructor and Description |
|---|
MappedPageFactoryImpl(int pageSize,
String pageDir,
long cacheTTL) |
MappedPageFactoryImpl(int pageSize,
String pageDir,
long cacheTTL,
Clock clock,
FileFactory fileFactory) |
| Modifier and Type | Method and Description |
|---|---|
IMappedPage |
acquirePage(long index)
Acquire a mapped page with specific index from the factory
|
void |
deleteAllPages()
thread unsafe, caller need synchronization
|
void |
deletePage(long index)
thread unsafe, caller need synchronization
|
void |
deletePages(Set<Long> indexes)
thread unsafe, caller need synchronization
|
void |
deletePagesBefore(long timestamp)
thread unsafe, caller need synchronization
|
void |
deletePagesBeforePageIndex(long pageIndex)
Delete all pages before the specific index
|
void |
flush()
thread unsafe, caller need synchronization
|
Set<String> |
getBackPageFileSet()
A set of back page file names
|
long |
getBackPageFileSize()
Total size of all page files
|
int |
getCacheSize()
For test, get current cache size
|
Set<Long> |
getExistingBackFileIndexSet()
For test, get a list of indexes of current existing back files.
|
long |
getFirstPageIndexBefore(long timestamp)
Get index of a page file with last modified timestamp closest to specific timestamp.
|
String |
getPageDir()
Current set page directory.
|
long |
getPageFileLastModifiedTime(long index)
Get last modified timestamp of page file index
|
Set<Long> |
getPageIndexSetBefore(long timestamp)
Get all indexes of pages with last modified timestamp before the specific timestamp.
|
int |
getPageSize()
Current set page size, when creating pages, the factory will
only create pages with this size.
|
void |
releaseCachedPages()
thread unsafe, caller need synchronization
|
void |
releasePage(long index)
Return the mapped page to the factory,
calling thread release the page to inform the factory that it has finished with the page,
so the factory get a chance to recycle the page to save memory.
|
public static final String PAGE_FILE_NAME
public static final String PAGE_FILE_SUFFIX
public MappedPageFactoryImpl(int pageSize,
String pageDir,
long cacheTTL,
Clock clock,
FileFactory fileFactory)
public MappedPageFactoryImpl(int pageSize,
String pageDir,
long cacheTTL)
public IMappedPage acquirePage(long index) throws IOException
IMappedPageFactoryacquirePage in interface IMappedPageFactoryindex - the index of the pageIOException - exception thrown if there was any IO error during the acquire operationpublic int getPageSize()
IMappedPageFactorygetPageSize in interface IMappedPageFactorypublic String getPageDir()
IMappedPageFactorygetPageDir in interface IMappedPageFactorypublic void releasePage(long index)
IMappedPageFactoryreleasePage in interface IMappedPageFactoryindex - the index of the pagepublic void releaseCachedPages()
throws IOException
releaseCachedPages in interface IMappedPageFactoryIOException - exception thrown if there was any IO error during the release operation.public void deleteAllPages()
throws IOException
deleteAllPages in interface IMappedPageFactoryIOException - exception thrown if there was any IO error during the delete operation.public void deletePages(Set<Long> indexes) throws IOException
deletePages in interface IMappedPageFactoryindexes - the indexes of the pagesIOException - exception thrown if IO error occurspublic void deletePage(long index)
throws IOException
deletePage in interface IMappedPageFactoryindex - the index of the pageIOException - exception thrown if there was any IO error during the delete operation.public Set<Long> getPageIndexSetBefore(long timestamp)
IMappedPageFactorygetPageIndexSetBefore in interface IMappedPageFactorytimestamp - the timestamp to checkpublic void deletePagesBefore(long timestamp)
throws IOException
deletePagesBefore in interface IMappedPageFactorytimestamp - the timestamp to checkIOException - exception thrown if IO error occurspublic void deletePagesBeforePageIndex(long pageIndex)
throws IOException
IMappedPageFactorydeletePagesBeforePageIndex in interface IMappedPageFactorypageIndex - page file index to checkIOException - exception thrown if there was any IO error during the delete operation.public Set<Long> getExistingBackFileIndexSet()
IMappedPageFactorygetExistingBackFileIndexSet in interface IMappedPageFactorypublic int getCacheSize()
IMappedPageFactorygetCacheSize in interface IMappedPageFactorypublic long getPageFileLastModifiedTime(long index)
IMappedPageFactorygetPageFileLastModifiedTime in interface IMappedPageFactoryindex - page indexpublic long getFirstPageIndexBefore(long timestamp)
IMappedPageFactorygetFirstPageIndexBefore in interface IMappedPageFactorytimestamp - the timestamp to checkpublic void flush()
flush in interface IMappedPageFactorypublic Set<String> getBackPageFileSet()
IMappedPageFactorygetBackPageFileSet in interface IMappedPageFactorypublic long getBackPageFileSize()
IMappedPageFactorygetBackPageFileSize in interface IMappedPageFactoryCopyright © 2020. All rights reserved.