Package org.kairosdb.bigqueue.page
Interface IMappedPageFactory
-
- All Known Implementing Classes:
MappedPageFactoryImpl
public interface IMappedPageFactoryMemory mapped page management ADT- Author:
- bulldog
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IMappedPageacquirePage(long index)Acquire a mapped page with specific index from the factoryvoiddeleteAllPages()delete all mapped pages currently available in this factory, this call will remove all pages from the cache and delete all back files.voiddeletePage(long index)delete a mapped page with specific index in this factory, this call will remove the page from the cache if it is cached and delete back file.voiddeletePages(Set<Long> indexes)delete mapped pages with a set of specific indexes in this factory, this call will remove the pages from the cache if they ware cached and delete back files.voiddeletePagesBefore(long timestamp)Delete all pages with last modified timestamp before the specific timestamp.voiddeletePagesBeforePageIndex(long pageIndex)Delete all pages before the specific indexvoidflush()Persist any changes in cached mapped pagesSet<String>getBackPageFileSet()A set of back page file nameslonggetBackPageFileSize()Total size of all page filesintgetCacheSize()For test, get current cache sizeSet<Long>getExistingBackFileIndexSet()For test, get a list of indexes of current existing back files.longgetFirstPageIndexBefore(long timestamp)Get index of a page file with last modified timestamp closest to specific timestamp.StringgetPageDir()Current set page directory.longgetPageFileLastModifiedTime(long index)Get last modified timestamp of page file indexSet<Long>getPageIndexSetBefore(long timestamp)Get all indexes of pages with last modified timestamp before the specific timestamp.intgetPageSize()Current set page size, when creating pages, the factory will only create pages with this size.voidreleaseCachedPages()remove all cached pages from the cache and close resources associated with the cached pages.voidreleasePage(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.
-
-
-
Method Detail
-
acquirePage
IMappedPage acquirePage(long index) throws IOException
Acquire a mapped page with specific index from the factory- Parameters:
index- the index of the page- Returns:
- a mapped page
- Throws:
IOException- exception thrown if there was any IO error during the acquire operation
-
releasePage
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.- Parameters:
index- the index of the page
-
getPageSize
int getPageSize()
Current set page size, when creating pages, the factory will only create pages with this size.- Returns:
- an integer number
-
getPageDir
String getPageDir()
Current set page directory.- Returns:
- directory name
-
deletePage
void deletePage(long index) throws IOExceptiondelete a mapped page with specific index in this factory, this call will remove the page from the cache if it is cached and delete back file.- Parameters:
index- the index of the page- Throws:
IOException- exception thrown if there was any IO error during the delete operation.
-
deletePages
void deletePages(Set<Long> indexes) throws IOException
delete mapped pages with a set of specific indexes in this factory, this call will remove the pages from the cache if they ware cached and delete back files.- Parameters:
indexes- the indexes of the pages- Throws:
IOException- exception thrown if IO error occurs
-
deleteAllPages
void deleteAllPages() throws IOExceptiondelete all mapped pages currently available in this factory, this call will remove all pages from the cache and delete all back files.- Throws:
IOException- exception thrown if there was any IO error during the delete operation.
-
releaseCachedPages
void releaseCachedPages() throws IOExceptionremove all cached pages from the cache and close resources associated with the cached pages.- Throws:
IOException- exception thrown if there was any IO error during the release operation.
-
getPageIndexSetBefore
Set<Long> getPageIndexSetBefore(long timestamp)
Get all indexes of pages with last modified timestamp before the specific timestamp.- Parameters:
timestamp- the timestamp to check- Returns:
- a set of indexes
-
deletePagesBefore
void deletePagesBefore(long timestamp) throws IOExceptionDelete all pages with last modified timestamp before the specific timestamp.- Parameters:
timestamp- the timestamp to check- Throws:
IOException- exception thrown if there was any IO error during the delete operation.
-
deletePagesBeforePageIndex
void deletePagesBeforePageIndex(long pageIndex) throws IOExceptionDelete all pages before the specific index- Parameters:
pageIndex- page file index to check- Throws:
IOException- exception thrown if there was any IO error during the delete operation.
-
getPageFileLastModifiedTime
long getPageFileLastModifiedTime(long index)
Get last modified timestamp of page file index- Parameters:
index- page index- Returns:
- last modified time
-
getFirstPageIndexBefore
long getFirstPageIndexBefore(long timestamp)
Get index of a page file with last modified timestamp closest to specific timestamp.- Parameters:
timestamp- the timestamp to check- Returns:
- a page index
-
getExistingBackFileIndexSet
Set<Long> getExistingBackFileIndexSet()
For test, get a list of indexes of current existing back files.- Returns:
- a set of indexes
-
getCacheSize
int getCacheSize()
For test, get current cache size- Returns:
- an integer number
-
flush
void flush()
Persist any changes in cached mapped pages
-
getBackPageFileSet
Set<String> getBackPageFileSet()
A set of back page file names- Returns:
- file name set
-
getBackPageFileSize
long getBackPageFileSize()
Total size of all page files- Returns:
- total size
-
-