@NotThreadSafe public class DefaultPageMetaStore extends Object implements PageMetaStore
Modifier and Type | Field and Description |
---|---|
protected ReentrantReadWriteLock |
mLock |
Constructor and Description |
---|
DefaultPageMetaStore(List<PageStoreDir> dirs) |
DefaultPageMetaStore(List<PageStoreDir> dirs,
Allocator allocator)
Constructor of DefaultMetaStore.
|
Modifier and Type | Method and Description |
---|---|
void |
addPage(PageId pageId,
PageInfo pageInfo)
Adds a new page to the cache.
|
void |
addTempPage(PageId pageId,
PageInfo pageInfo)
Adds a new temp page to the cache.
|
PageStoreDir |
allocate(String fileId,
long fileLength) |
long |
bytes() |
void |
commitFile(String fileId,
String newFileId)
Commits a temp file so that all its pages become permanent.
|
PageInfo |
evict(CacheScope scope,
PageStoreDir pageStoreDir) |
Set<PageInfo> |
getAllPagesByFileId(String fileId)
Gets all pages by the specified File ID.
|
ReentrantReadWriteLock |
getLock() |
PageInfo |
getPageInfo(PageId pageId) |
PageStoreDir |
getStoreDirOfFile(String fileId)
Gets the store dir which the specified file is assigned to be cached in.
|
List<PageStoreDir> |
getStoreDirs()
Gets the storage directories.
|
Optional<CacheUsage> |
getUsage()
Gets cache usage.
|
boolean |
hasPage(PageId pageId) |
long |
numPages() |
PageInfo |
removePage(PageId pageId)
Removes a page.
|
PageInfo |
removePage(PageId pageId,
boolean isTemporary)
Removes a page.
|
void |
reset()
Resets the meta store.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
create, evict
protected final ReentrantReadWriteLock mLock
public DefaultPageMetaStore(List<PageStoreDir> dirs)
dirs
- storage directoriespublic DefaultPageMetaStore(List<PageStoreDir> dirs, Allocator allocator)
dirs
- storage directoriesallocator
- storage allocatorpublic ReentrantReadWriteLock getLock()
getLock
in interface PageMetaStore
public boolean hasPage(PageId pageId)
hasPage
in interface PageMetaStore
pageId
- page identifierpublic void addPage(PageId pageId, PageInfo pageInfo)
PageMetaStore
addPage
in interface PageMetaStore
pageId
- page identifierpageInfo
- info of the pagepublic void addTempPage(PageId pageId, PageInfo pageInfo)
PageMetaStore
addTempPage
in interface PageMetaStore
pageId
- page identifierpageInfo
- info of the pagepublic void commitFile(String fileId, String newFileId) throws PageNotFoundException
PageMetaStore
commitFile
in interface PageMetaStore
fileId
- the temp file to commitnewFileId
- the new file name of the file after committingPageNotFoundException
public PageStoreDir getStoreDirOfFile(String fileId) throws FileDoesNotExistException
PageMetaStore
getStoreDirOfFile
in interface PageMetaStore
fileId
- the file IDFileDoesNotExistException
- if the file is not being cachedpublic List<PageStoreDir> getStoreDirs()
PageMetaStore
getStoreDirs
in interface PageMetaStore
public PageStoreDir allocate(String fileId, long fileLength)
allocate
in interface PageMetaStore
public PageInfo getPageInfo(PageId pageId) throws PageNotFoundException
getPageInfo
in interface PageMetaStore
pageId
- page identifierPageNotFoundException
public PageInfo removePage(PageId pageId, boolean isTemporary) throws PageNotFoundException
PageMetaStore
removePage
in interface PageMetaStore
pageId
- page identifierisTemporary
- whether is it temporary page or notPageNotFoundException
public PageInfo removePage(PageId pageId) throws PageNotFoundException
PageMetaStore
removePage
in interface PageMetaStore
pageId
- page identifierPageNotFoundException
public long bytes()
bytes
in interface PageMetaStore
public long numPages()
numPages
in interface PageMetaStore
public void reset()
PageMetaStore
reset
in interface PageMetaStore
@Nullable public PageInfo evict(CacheScope scope, PageStoreDir pageStoreDir)
evict
in interface PageMetaStore
public Set<PageInfo> getAllPagesByFileId(String fileId)
PageMetaStore
getAllPagesByFileId
in interface PageMetaStore
fileId
- the target file idpublic Optional<CacheUsage> getUsage()
CacheStatus
getUsage
in interface CacheStatus
Copyright © 2023. All Rights Reserved.